cameron314 / cameron314/concurrentqueue
In some cases, the order of values retrieved by calling try_dequeue does not match the order in which the values were placed by enqueue.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 12.5k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Call Sequence:
1 call to enqueue, inserting value 4.
2.After a 50ms interval, second call to enqueue, inserting value 0.
3.Within less than 1ms, first call to try_dequeue, retrieving value 0.
4Within less than 1ms, second call to try_dequeue, retrieving value 4.
The first enqueue operation (ImplicitProducer::enqueue) inserts value 4 into an instance (e.g., 0x0000007f28001920).
The second enqueue operation (ImplicitProducer::enqueue) inserts value 0 into a different instance (e.g., 0x0000007f2c0103a0).
The first try_dequeue operation selects the instance (0x0000007f2c0103a0) based on a "best" scoring mechanism and retrieves value 0.
The second try_dequeue operation selects the instance (0x0000007f28001920) based on the same mechanism and retrieves value 4.
Is there a solution to ensure that the dequeue order matches the enqueue order in this scenario?
We checked the code and appended the log and found
For data 0 and data 4, the bestSize calculation is 1, resulting in the wrong order of data when retrieving.
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 by reading ImplicitProducer::enqueue and try_dequeue, then trace the reported "best" scoring mechanism and bestSize calculation for the two producer instances. Compare the observed selection order with the queue's stated ordering guarantees; done means establishing whether global FIFO is supported and, if so, identifying the scope of a correct fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100