aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2024-12-18 19:08:08 +0300
committermikhnenko <mikhnenko@yandex-team.com>2024-12-18 19:29:26 +0300
commit7ed76959e6c06dbc4c249ce0f3b930463a6b65db (patch)
tree0e9528cb7261812a5ae7ed177048721eaebf8ed0 /contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp
parent4c8e7f015711b5175d63e1a87cbd40c49ce7aa70 (diff)
downloadydb-7ed76959e6c06dbc4c249ce0f3b930463a6b65db.tar.gz
libc++: Run clang-format from upstream and update to 9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7
commit_hash:ca4954fe054e5a7190ad11ab71bfc7ca0965bca2
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp')
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp95
1 files changed, 38 insertions, 57 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp b/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp
index 33e19568b4..db60571cf5 100644
--- a/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp
@@ -20,69 +20,50 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// ~condition_variable is defined elsewhere.
-void
-condition_variable::notify_one() noexcept
-{
- __libcpp_condvar_signal(&__cv_);
-}
+void condition_variable::notify_one() noexcept { __libcpp_condvar_signal(&__cv_); }
-void
-condition_variable::notify_all() noexcept
-{
- __libcpp_condvar_broadcast(&__cv_);
-}
+void condition_variable::notify_all() noexcept { __libcpp_condvar_broadcast(&__cv_); }
-void
-condition_variable::wait(unique_lock<mutex>& lk) noexcept
-{
- if (!lk.owns_lock())
- __throw_system_error(EPERM,
- "condition_variable::wait: mutex not locked");
- int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
- if (ec)
- __throw_system_error(ec, "condition_variable wait failed");
+void condition_variable::wait(unique_lock<mutex>& lk) noexcept {
+ if (!lk.owns_lock())
+ __throw_system_error(EPERM, "condition_variable::wait: mutex not locked");
+ int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
+ if (ec)
+ __throw_system_error(ec, "condition_variable wait failed");
}
-void
-condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
- chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) noexcept
-{
- using namespace chrono;
- if (!lk.owns_lock())
- __throw_system_error(EPERM,
- "condition_variable::timed wait: mutex not locked");
- nanoseconds d = tp.time_since_epoch();
- if (d > nanoseconds(0x59682F000000E941))
- d = nanoseconds(0x59682F000000E941);
- __libcpp_timespec_t ts;
- seconds s = duration_cast<seconds>(d);
- typedef decltype(ts.tv_sec) ts_sec;
- constexpr ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
- if (s.count() < ts_sec_max)
- {
- ts.tv_sec = static_cast<ts_sec>(s.count());
- ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
- }
- else
- {
- ts.tv_sec = ts_sec_max;
- ts.tv_nsec = giga::num - 1;
- }
- int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
- if (ec != 0 && ec != ETIMEDOUT)
- __throw_system_error(ec, "condition_variable timed_wait failed");
+void condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
+ chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) noexcept {
+ using namespace chrono;
+ if (!lk.owns_lock())
+ __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked");
+ nanoseconds d = tp.time_since_epoch();
+ if (d > nanoseconds(0x59682F000000E941))
+ d = nanoseconds(0x59682F000000E941);
+ __libcpp_timespec_t ts;
+ seconds s = duration_cast<seconds>(d);
+ typedef decltype(ts.tv_sec) ts_sec;
+ constexpr ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
+ if (s.count() < ts_sec_max) {
+ ts.tv_sec = static_cast<ts_sec>(s.count());
+ ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
+ } else {
+ ts.tv_sec = ts_sec_max;
+ ts.tv_nsec = giga::num - 1;
+ }
+ int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
+ if (ec != 0 && ec != ETIMEDOUT)
+ __throw_system_error(ec, "condition_variable timed_wait failed");
}
-void
-notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
-{
- auto& tl_ptr = __thread_local_data();
- // If this thread was not created using std::thread then it will not have
- // previously allocated.
- if (tl_ptr.get() == nullptr) {
- tl_ptr.set_pointer(new __thread_struct);
- }
- __thread_local_data()->notify_all_at_thread_exit(&cond, lk.release());
+void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk) {
+ auto& tl_ptr = __thread_local_data();
+ // If this thread was not created using std::thread then it will not have
+ // previously allocated.
+ if (tl_ptr.get() == nullptr) {
+ tl_ptr.set_pointer(new __thread_struct);
+ }
+ __thread_local_data()->notify_all_at_thread_exit(&cond, lk.release());
}
_LIBCPP_END_NAMESPACE_STD