diff --git a/Chapter04/worker.cpp b/Chapter04/worker.cpp index e8db894..4554c9f 100644 --- a/Chapter04/worker.cpp +++ b/Chapter04/worker.cpp @@ -31,6 +31,7 @@ void Worker::getCondition(condition_variable* &cv) { // --- RUN --- // Runs the worker instance. void Worker::run() { + unique_lock ulock(mtx); while (running) { if (ready) { // Execute the request. diff --git a/Chapter04/worker.h b/Chapter04/worker.h index 109ce1d..15af25f 100644 --- a/Chapter04/worker.h +++ b/Chapter04/worker.h @@ -26,13 +26,13 @@ using namespace std; class Worker { condition_variable cv; mutex mtx; - unique_lock ulock; + //unique_lock ulock; AbstractRequest* request; bool running; bool ready; public: - Worker() { running = true; ready = false; ulock = unique_lock(mtx); } + Worker() { running = true; ready = false; } void run(); void stop() { running = false; } void setRequest(AbstractRequest* request) { this->request = request; ready = true; }