cameron314 / cameron314/concurrentqueue
why ocassionally unexcepted clear queue
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 12.5k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's sample producer and worker loop, focusing on the relationship between wait_dequeue_timed and size_approx(). Reproduce the reported drop if possible and determine whether the zero is an approximate observation or indicates lost items; document the cause and a reliable way to verify queue contents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100