@@ -3039,7 +3039,7 @@ class ConcurrentQueue
30393039 return create<Block>();
30403040 }
30413041 else {
3042- return nullptr ;
3042+ return nullptr ;
30433043 }
30443044 }
30453045
@@ -3269,52 +3269,56 @@ class ConcurrentQueue
32693269
32703270 inline void populate_initial_implicit_producer_hash ()
32713271 {
3272- MOODYCAMEL_CONSTEXPR_IF (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE == 0 ) return ;
3273- else {
3274- implicitProducerHashCount.store (0 , std::memory_order_relaxed);
3275- auto hash = &initialImplicitProducerHash;
3276- hash->capacity = INITIAL_IMPLICIT_PRODUCER_HASH_SIZE;
3277- hash->entries = &initialImplicitProducerHashEntries[0 ];
3278- for (size_t i = 0 ; i != INITIAL_IMPLICIT_PRODUCER_HASH_SIZE; ++i) {
3279- initialImplicitProducerHashEntries[i].key .store (details::invalid_thread_id, std::memory_order_relaxed);
3272+ MOODYCAMEL_CONSTEXPR_IF (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE == 0 ) {
3273+ return ;
32803274 }
3281- hash->prev = nullptr ;
3282- implicitProducerHash.store (hash, std::memory_order_relaxed);
3275+ else {
3276+ implicitProducerHashCount.store (0 , std::memory_order_relaxed);
3277+ auto hash = &initialImplicitProducerHash;
3278+ hash->capacity = INITIAL_IMPLICIT_PRODUCER_HASH_SIZE;
3279+ hash->entries = &initialImplicitProducerHashEntries[0 ];
3280+ for (size_t i = 0 ; i != INITIAL_IMPLICIT_PRODUCER_HASH_SIZE; ++i) {
3281+ initialImplicitProducerHashEntries[i].key .store (details::invalid_thread_id, std::memory_order_relaxed);
3282+ }
3283+ hash->prev = nullptr ;
3284+ implicitProducerHash.store (hash, std::memory_order_relaxed);
32833285 }
32843286 }
32853287
32863288 void swap_implicit_producer_hashes (ConcurrentQueue& other)
32873289 {
3288- MOODYCAMEL_CONSTEXPR_IF (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE == 0 ) return ;
3289- else {
3290- // Swap (assumes our implicit producer hash is initialized)
3291- initialImplicitProducerHashEntries.swap (other.initialImplicitProducerHashEntries );
3292- initialImplicitProducerHash.entries = &initialImplicitProducerHashEntries[0 ];
3293- other.initialImplicitProducerHash .entries = &other.initialImplicitProducerHashEntries [0 ];
3294-
3295- details::swap_relaxed (implicitProducerHashCount, other.implicitProducerHashCount );
3296-
3297- details::swap_relaxed (implicitProducerHash, other.implicitProducerHash );
3298- if (implicitProducerHash.load (std::memory_order_relaxed) == &other.initialImplicitProducerHash ) {
3299- implicitProducerHash.store (&initialImplicitProducerHash, std::memory_order_relaxed);
3290+ MOODYCAMEL_CONSTEXPR_IF (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE == 0 ) {
3291+ return ;
33003292 }
33013293 else {
3302- ImplicitProducerHash* hash;
3303- for (hash = implicitProducerHash.load (std::memory_order_relaxed); hash->prev != &other.initialImplicitProducerHash ; hash = hash->prev ) {
3304- continue ;
3294+ // Swap (assumes our implicit producer hash is initialized)
3295+ initialImplicitProducerHashEntries.swap (other.initialImplicitProducerHashEntries );
3296+ initialImplicitProducerHash.entries = &initialImplicitProducerHashEntries[0 ];
3297+ other.initialImplicitProducerHash .entries = &other.initialImplicitProducerHashEntries [0 ];
3298+
3299+ details::swap_relaxed (implicitProducerHashCount, other.implicitProducerHashCount );
3300+
3301+ details::swap_relaxed (implicitProducerHash, other.implicitProducerHash );
3302+ if (implicitProducerHash.load (std::memory_order_relaxed) == &other.initialImplicitProducerHash ) {
3303+ implicitProducerHash.store (&initialImplicitProducerHash, std::memory_order_relaxed);
33053304 }
3306- hash->prev = &initialImplicitProducerHash;
3307- }
3308- if (other.implicitProducerHash .load (std::memory_order_relaxed) == &initialImplicitProducerHash) {
3309- other.implicitProducerHash .store (&other.initialImplicitProducerHash , std::memory_order_relaxed);
3310- }
3311- else {
3312- ImplicitProducerHash* hash;
3313- for (hash = other.implicitProducerHash .load (std::memory_order_relaxed); hash->prev != &initialImplicitProducerHash; hash = hash->prev ) {
3314- continue ;
3305+ else {
3306+ ImplicitProducerHash* hash;
3307+ for (hash = implicitProducerHash.load (std::memory_order_relaxed); hash->prev != &other.initialImplicitProducerHash ; hash = hash->prev ) {
3308+ continue ;
3309+ }
3310+ hash->prev = &initialImplicitProducerHash;
3311+ }
3312+ if (other.implicitProducerHash .load (std::memory_order_relaxed) == &initialImplicitProducerHash) {
3313+ other.implicitProducerHash .store (&other.initialImplicitProducerHash , std::memory_order_relaxed);
3314+ }
3315+ else {
3316+ ImplicitProducerHash* hash;
3317+ for (hash = other.implicitProducerHash .load (std::memory_order_relaxed); hash->prev != &initialImplicitProducerHash; hash = hash->prev ) {
3318+ continue ;
3319+ }
3320+ hash->prev = &other.initialImplicitProducerHash ;
33153321 }
3316- hash->prev = &other.initialImplicitProducerHash ;
3317- }
33183322 }
33193323 }
33203324
0 commit comments