aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2022-08-08 20:45:08 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2022-08-08 20:45:08 +0300
commit775728b3e92dec038c56f4f12fb48ef4d053cbc9 (patch)
tree440f127663e6da96542493e4bf8c0fd24abe5608 /library
parent74dcc580b7a2011a5bb44e20d1f4fa2a5275e0f9 (diff)
downloadydb-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.cpp12
-rw-r--r--library/cpp/yt/threading/fork_aware_spin_lock.h1
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;