diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-08 20:45:08 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2022-08-08 20:45:08 +0300 |
commit | 775728b3e92dec038c56f4f12fb48ef4d053cbc9 (patch) | |
tree | 440f127663e6da96542493e4bf8c0fd24abe5608 /library | |
parent | 74dcc580b7a2011a5bb44e20d1f4fa2a5275e0f9 (diff) | |
download | ydb-775728b3e92dec038c56f4f12fb48ef4d053cbc9.tar.gz |
Update contrib/restricted/boost/format to 1.79.0
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/yt/threading/fork_aware_spin_lock.cpp | 12 | ||||
-rw-r--r-- | library/cpp/yt/threading/fork_aware_spin_lock.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/library/cpp/yt/threading/fork_aware_spin_lock.cpp b/library/cpp/yt/threading/fork_aware_spin_lock.cpp index 844d80ea7a..f43411b6d8 100644 --- a/library/cpp/yt/threading/fork_aware_spin_lock.cpp +++ b/library/cpp/yt/threading/fork_aware_spin_lock.cpp @@ -12,6 +12,18 @@ void TForkAwareSpinLock::Acquire() noexcept SpinLock_.Acquire(); } +bool TForkAwareSpinLock::TryAcquire() noexcept +{ + if (!GetForkLock()->TryAcquireReaderForkFriendly()) { + return false; + } + if (!SpinLock_.TryAcquire()) { + GetForkLock()->ReleaseReader(); + return false; + } + return true; +} + void TForkAwareSpinLock::Release() noexcept { SpinLock_.Release(); diff --git a/library/cpp/yt/threading/fork_aware_spin_lock.h b/library/cpp/yt/threading/fork_aware_spin_lock.h index c6487ce4b0..1d69aa1bca 100644 --- a/library/cpp/yt/threading/fork_aware_spin_lock.h +++ b/library/cpp/yt/threading/fork_aware_spin_lock.h @@ -24,6 +24,7 @@ public: { } void Acquire() noexcept; + bool TryAcquire() noexcept; void Release() noexcept; bool IsLocked() const noexcept; |