Document try_enqueue implicit producer index limit (#418)#446
Open
PavelGuzenfeld wants to merge 2 commits intocameron314:masterfrom
Open
Document try_enqueue implicit producer index limit (#418)#446PavelGuzenfeld wants to merge 2 commits intocameron314:masterfrom
PavelGuzenfeld wants to merge 2 commits intocameron314:masterfrom
Conversation
…le-cast compliance Projects using -Wold-style-cast and -Wuseless-cast (common in modern C++ codebases with strict warning policies) cannot compile concurrentqueue without warnings. Changes: - lightweightsemaphore.h: Replace C-style casts with static_cast in timed_wait, waitWithPartialSpinning, waitManyWithPartialSpinning, and signal methods - blockingconcurrentqueue.h: Replace C-style casts with static_cast for sema->signal, sema->waitMany, sema->tryWaitMany, sema->availableApprox calls and constructor MAX_SEMA_SPINS; replace C-style pointer casts in assert with reinterpret_cast - concurrentqueue.h: Suppress -Wuseless-cast around hash_thread_id static_cast that is needed for cross-platform correctness but redundant on 64-bit Tested clean with GCC 14/15, C++17/20/23, using -Wall -Wextra -Wpedantic -Werror -Wold-style-cast -Wuseless-cast -Wconversion -Wsign-conversion and other strict flags.
…ameron314#418) try_enqueue() fails around BLOCK_SIZE * IMPLICIT_INITIAL_INDEX_SIZE elements per implicit producer because the block index (not the blocks) must grow, which requires allocation that try_enqueue refuses to do. Pre-allocating blocks via the constructor does not help. Added documentation comments near IMPLICIT_INITIAL_INDEX_SIZE in the default traits and near the try_enqueue method explaining the limit and workarounds. Added implicit_producer_index_limit unit test demonstrating the issue and verifying both workarounds (enqueue() and larger IMPLICIT_INITIAL_INDEX_SIZE).
911509e to
1a7c45f
Compare
Author
|
Hi @cameron314, just a friendly ping on this PR. Would you have a chance to take a look when convenient? Happy to address any feedback. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConcurrentQueueDefaultTraits::IMPLICIT_INITIAL_INDEX_SIZEexplaining the relationship betweenBLOCK_SIZE,IMPLICIT_INITIAL_INDEX_SIZE, and the maximum elements per implicit producer when usingtry_enqueuetry_enqueuemethod that pre-allocating blocks via the constructor does not increase the block index sizeimplicit_producer_index_limitunit test demonstrating the limit and both workarounds (useenqueue()or increaseIMPLICIT_INITIAL_INDEX_SIZE)Test plan
implicit_producer_index_limitpasses (8 iterations, all green)Fixes #418