: name(name)
{
c = new boost::condition_variable;
- m = new boost::mutex;
t = NULL;
}
Client::~Client()
{
+ // TODO
}
if (!t)
t = new boost::thread(boost::bind(&Client::worker, this));
- boost::unique_lock<boost::mutex> l(*m);
+ boost::unique_lock<boost::mutex> l(m);
tasks.push(Task(conn, msg));
l.unlock();
}
+
void
Client::worker()
{
while (true)
{
- boost::unique_lock<boost::mutex> l(*m);
+ boost::unique_lock<boost::mutex> l(m);
while (tasks.empty())
c->wait(l);
{
assert(find(name) == entries.end());
- entries.push_back(Client(name));
+ entries.emplace_back(name);
return --entries.end();
}
};
-class Client : public Commands
+class Client : public Commands, boost::noncopyable
{
public:
};
boost::condition_variable* c;
- boost::mutex* m;
+ boost::mutex m;
boost::thread* t;
queue<Task> tasks;