diff --git a/include/c11log/details/blocking_queue.h b/include/c11log/details/blocking_queue.h index 4d380707..92a3ca63 100644 --- a/include/c11log/details/blocking_queue.h +++ b/include/c11log/details/blocking_queue.h @@ -95,8 +95,11 @@ public: // Clear the queue void clear() { - T item; - while (pop(item, std::chrono::milliseconds(0))); + { + std::unique_lock ul(mutex_); + q_ = queue_t{}; + } + item_popped_cond_.notify_all(); } private: diff --git a/src/test.cpp b/src/test.cpp index 99fd892d..58e143af 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -70,7 +70,7 @@ void popper(Q* q) string output; while(active) { - q->pop(output); + q->pop(output); ++pop_count; } } @@ -80,13 +80,6 @@ void testq(int size, int pushers, int poppers) active = true; Q q{static_cast(size)}; - /* - A a; - q.push(a); - std::cout << "Befor pop..\n"; - q.pop(a); - return; - */ for(int i = 0; i < poppers; i++) new std::thread(std::bind(popper, &q));