summaryrefslogtreecommitdiffstats
path: root/library/cpp/threading/equeue
diff options
context:
space:
mode:
authorponasenko-rs <[email protected]>2026-03-18 22:57:43 +0300
committerponasenko-rs <[email protected]>2026-03-18 23:31:03 +0300
commit7208bf5e47f84b72e05b69156d070ab5460c6aa7 (patch)
tree497a175204c66355869f9c99fb0d370e83996c64 /library/cpp/threading/equeue
parente156035788bddca3eb74b11bddc9afc4256d1f7b (diff)
YT-27514: Sync yt moody camel to 593df78ec309be7a7b456b3334025ccade1d2d66
``` curl https://raw.githubusercontent.com/cameron314/concurrentqueue/593df78ec309be7a7b456b3334025ccade1d2d66/concurrentqueue.h -o yt/yt/core/concurrency/moody_camel_concurrent_queue.h sed -i ' s/\t/ /g s/template</template </g s/memory_order_/memory_order::/g s/ *$//g s:\(^#include.*relacy.*"$\):\1 // Y_IGNORE: s:\(#include .*concurrentqueue_internal_debug.h"$\):\1 //Y_IGNORE: s:#include <atomic> // Requires C++11. Sorry VS2010.:#include <atomic> // Requires C++11. Sorry VS2010.: s:#include <climits> // for CHAR_BIT:#include <climits> // for CHAR_BIT: s:#include <thread> // partly for __WINPTHREADS_VERSION if on MinGW-w64 w/ POSIX threading:#include <thread> // partly for __WINPTHREADS_VERSION if on MinGW-w64 w/ POSIX threading: s:static const thread_id_t invalid_thread_id2 = 0xFFFFFFFFU; // Not technically guaranteed to be invalid, but is never used in practice. Note that all Win32 thread IDs are presently multiples of 4.:static const thread_id_t invalid_thread_id2 = 0xFFFFFFFFU; // Not technically guaranteed to be invalid, but is never used in practice. Note that all Win32 thread IDs are presently multiples of 4.: s:ThreadExitListener\* next; // reserved for use by the ThreadExitNotifier:ThreadExitListener* next; // reserved for use by the ThreadExitNotifier: s-#pragma warning(disable: 4307) // + integral constant overflow (that'"'"'s what the ternary expression is for!)-#pragma warning(disable: 4307) // + integral constant overflow (that'"'"'s what the ternary expression is for!)- s-#pragma warning(disable: 4309) // static_cast: Truncation of constant value-#pragma warning(disable: 4309) // static_cast: Truncation of constant value- s:if (prev != nullptr) { // The last hash is part of this object and was not allocated dynamically:if (prev != nullptr) { // The last hash is part of this object and was not allocated dynamically: s:^ add_knowing_refcount_is_zero(node);$: add_knowing_refcount_is_zero(node);: s:bool dynamicallyAllocated; // Perhaps a better name for this would be '"'"'isNotPartOfInitialBlockPool'"'"':bool dynamicallyAllocated; // Perhaps a better name for this would be '"'"'isNotPartOfInitialBlockPool'"'"': s%std::atomic<index_t> tailIndex; // Where to enqueue to next%std::atomic<index_t> tailIndex; // Where to enqueue to next% s%std::atomic<index_t> headIndex; // Where to dequeue from next%std::atomic<index_t> headIndex; // Where to dequeue from next% s:new_block_index(0); // This creates an index with double the number of current entries, i.e. EXPLICIT_INITIAL_INDEX_SIZE:new_block_index(0); // This creates an index with double the number of current entries, i.e. EXPLICIT_INITIAL_INDEX_SIZE: s:if (this->tailBlock != nullptr) { // Note this means there must be a block index too:if (this->tailBlock != nullptr) { // Note this means there must be a block index too: s:size_t i = 0; // Offset into block:size_t i = 0; // Offset into block: s%this->dequeueOvercommit.fetch_add(1, std::memory_order::release); // Release so that the fetch_add on dequeueOptimisticCount is guaranteed to happen before this write%this->dequeueOvercommit.fetch_add(1, std::memory_order::release); // Release so that the fetch_add on dequeueOptimisticCount is guaranteed to happen before this write% s%std::atomic<size_t> front; // Current slot (not next, like pr_blockIndexFront)%std::atomic<size_t> front; // Current slot (not next, like pr_blockIndexFront)% s:size_t pr_blockIndexFront; // Next slot (not current):size_t pr_blockIndexFront; // Next slot (not current): s%auto localBlockIndex = blockIndex.load(std::memory_order::relaxed); // We'"'"'re the only writer thread, relaxed is OK%auto localBlockIndex = blockIndex.load(std::memory_order::relaxed); // We'"'"'re the only writer thread, relaxed is OK% s:/\* desired \*/:/*desired*/: s:while (true) { // Not an infinite loop because at least one slot is free in the hash table:while (true) { // Not an infinite loop because at least one slot is free in the hash table: s$mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order::seq_cst, std::memory_order::relaxed$mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order::seq_cst, std::memory_order::relaxed$ s$mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order::seq_cst, std::memory_order::relaxed)$mainHash->entries[index].key.compare_exchange_strong(empty, id, std::memory_order::seq_cst, std::memory_order::relaxed)$ s:break; // Not in this hash table:break; // Not in this hash table: s$while (probedKey != details::invalid_thread_id); // Can happen if the hash has changed but we weren'"'"'t put back in it yet, or if we weren'"'"'t added to this hash in the first place$while (probedKey != details::invalid_thread_id); // Can happen if the hash has changed but we weren'"'"'t put back in it yet, or if we weren'"'"'t added to this hash in the first place$ s$std::atomic<size_t> implicitProducerHashCount; // Number of slots logically used$std::atomic<size_t> implicitProducerHashCount; // Number of slots logically used$ ' yt/yt/core/concurrency/moody_camel_concurrent_queue.h ``` commit_hash:945a49fc1afa8bf5c172e021f1c2440b8f9e0b7d
Diffstat (limited to 'library/cpp/threading/equeue')
0 files changed, 0 insertions, 0 deletions