diff options
author | vadim-xd <vadim-xd@yandex-team.com> | 2025-05-07 21:02:53 +0300 |
---|---|---|
committer | vadim-xd <vadim-xd@yandex-team.com> | 2025-05-07 21:18:56 +0300 |
commit | 74925a0d03c5922a2ac9dc2e5f63ee3088e203c7 (patch) | |
tree | 49a7f81f5e0586a776c3f7ac6a578317a5fd3d95 /library/cpp | |
parent | 83f4a82e4d23a88675d6b77e690c57c0f88a8144 (diff) | |
download | ydb-74925a0d03c5922a2ac9dc2e5f63ee3088e203c7.tar.gz |
TConcurrentHashMap::Exchange
commit_hash:09134890fc4d5d1267d6efa21bff48235205e6e5
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/containers/concurrent_hash/concurrent_hash.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/library/cpp/containers/concurrent_hash/concurrent_hash.h b/library/cpp/containers/concurrent_hash/concurrent_hash.h index 6fed13ee8d5..204434a9783 100644 --- a/library/cpp/containers/concurrent_hash/concurrent_hash.h +++ b/library/cpp/containers/concurrent_hash/concurrent_hash.h @@ -1,6 +1,7 @@ #pragma once #include <util/generic/hash.h> +#include <util/generic/utility.h> #include <util/system/spinlock.h> #include <array> @@ -103,6 +104,12 @@ public: bucket.Map[key] = value; } + void Exchange(const K& key, V& value) { + TBucket& bucket = GetBucketForKey(key); + TBucketGuard guard(bucket.Mutex); + DoSwap(bucket.Map[key], value); + } + void InsertUnique(const K& key, const V& value) { TBucket& bucket = GetBucketForKey(key); TBucketGuard guard(bucket.Mutex); |