concurrentqueue icon indicating copy to clipboard operation
concurrentqueue copied to clipboard

why ocassionally unexcepted clear queue

Open manuel76413 opened this issue 5 months ago • 3 comments

I write a parallel program that uses concurrent-queue, and most time it runs ok with very high performance. however, in an unknown situation, when the queue has about one million items, it will be empty in an unexcepted way, so I will lost many many jobs which should be in the queue.

my code is like :

moodycamel::BlockingConcurrentQueue m_fast_queue; bool br = m_fast_queue.enqueue(start_job); ... void worker(int tid) { std::string itm; while (!m_stop_workThreads.load()) { bool br = m_fast_queue.wait_dequeue_timed(itm, std::chrono::milliseconds(25)); if (br && !itm.empty()) { ++m_active_workThreads; do_job(itm); --m_active_workThreads; } } }

the information while run, I print to console window, like: -task:14733521-err:418891-queue:5103320 -task:14733521-err:418892-queue:5103297 -task:14733521-err:419156-queue:5103018 -task:14747550-err:419283-queue:0

the last row shows the queue size suddenly dropping to 0, queue size by call m_fast_queue.size_approx().

================= so anybody can give some advice, on why this happened?

manuel76413 avatar Sep 06 '24 14:09 manuel76413