int main() { boost::thread pop_sync1(&popper_sync); boost::thread pop_sync2(&popper_sync); boost::thread pop_sync3(&popper_sync); boost::thread push1(&pusher); boost::thread push2(&pusher); boost::thread push3(&pusher); // Waiting for all the tasks to push push1.join(); push2.join(); push3.join(); g_queue.flush(); // Waiting for all the tasks to pop pop_sync1.join(); pop_sync2.join(); pop_sync3.join(); // Asserting that no tasks remained, // and falling though without blocking assert(!g_queue.try_pop_task()); g_queue.push_task(&do_nothing); // Asserting that there is a task, // and falling though without blocking assert(g_queue.try_pop_task()); }
void pusher() { for (std::size_t i = 0; i < tests_tasks_count; ++i) { // Adding task to do nothing g_queue.push_task(&do_nothing); } }