#pragma once #include #include #include #include /** * Work item intended to stop all worker threads temporarily, detect that all are stopped using a * barrier, and restarting them using the same barrier. * Example: * Barrier workerBarrier(numWorkers + 1); * * workerBarrier.wait(); // Wait for all workers to stop * * workerBarrier.wait(); // restart the workers */ class BarrierWork : public Work { public: BarrierWork(Barrier* barrier) : barrier(barrier) { } virtual ~BarrierWork() { } void process(char*, unsigned, char*, unsigned) { LOG_DBG(WORKQUEUES, DEBUG, "Start blocking."); barrier->wait(); barrier->wait(); LOG_DBG(WORKQUEUES, DEBUG, "Done."); } private: Barrier* barrier; };