diff options
author | thegeorg <thegeorg@yandex-team.ru> | 2022-02-10 16:45:12 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:12 +0300 |
commit | 49116032d905455a7b1c994e4a696afc885c1e71 (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/restricted/abseil-cpp/absl/synchronization/blocking_counter.cc | |
parent | 4e839db24a3bbc9f1c610c43d6faaaa99824dcca (diff) | |
download | ydb-49116032d905455a7b1c994e4a696afc885c1e71.tar.gz |
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/restricted/abseil-cpp/absl/synchronization/blocking_counter.cc')
-rw-r--r-- | contrib/restricted/abseil-cpp/absl/synchronization/blocking_counter.cc | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/contrib/restricted/abseil-cpp/absl/synchronization/blocking_counter.cc b/contrib/restricted/abseil-cpp/absl/synchronization/blocking_counter.cc index cd660b3f0c..d2f82da3bb 100644 --- a/contrib/restricted/abseil-cpp/absl/synchronization/blocking_counter.cc +++ b/contrib/restricted/abseil-cpp/absl/synchronization/blocking_counter.cc @@ -14,37 +14,37 @@ #include "absl/synchronization/blocking_counter.h" -#include <atomic> - +#include <atomic> + #include "absl/base/internal/raw_logging.h" namespace absl { ABSL_NAMESPACE_BEGIN -namespace { - -// Return whether int *arg is true. -bool IsDone(void *arg) { return *reinterpret_cast<bool *>(arg); } - -} // namespace - -BlockingCounter::BlockingCounter(int initial_count) - : count_(initial_count), - num_waiting_(0), - done_{initial_count == 0 ? true : false} { - ABSL_RAW_CHECK(initial_count >= 0, "BlockingCounter initial_count negative"); +namespace { + +// Return whether int *arg is true. +bool IsDone(void *arg) { return *reinterpret_cast<bool *>(arg); } + +} // namespace + +BlockingCounter::BlockingCounter(int initial_count) + : count_(initial_count), + num_waiting_(0), + done_{initial_count == 0 ? true : false} { + ABSL_RAW_CHECK(initial_count >= 0, "BlockingCounter initial_count negative"); } bool BlockingCounter::DecrementCount() { - int count = count_.fetch_sub(1, std::memory_order_acq_rel) - 1; - ABSL_RAW_CHECK(count >= 0, - "BlockingCounter::DecrementCount() called too many times"); - if (count == 0) { - MutexLock l(&lock_); - done_ = true; - return true; + int count = count_.fetch_sub(1, std::memory_order_acq_rel) - 1; + ABSL_RAW_CHECK(count >= 0, + "BlockingCounter::DecrementCount() called too many times"); + if (count == 0) { + MutexLock l(&lock_); + done_ = true; + return true; } - return false; + return false; } void BlockingCounter::Wait() { @@ -55,10 +55,10 @@ void BlockingCounter::Wait() { ABSL_RAW_CHECK(num_waiting_ == 0, "multiple threads called Wait()"); num_waiting_++; - this->lock_.Await(Condition(IsDone, &this->done_)); + this->lock_.Await(Condition(IsDone, &this->done_)); - // At this point, we know that all threads executing DecrementCount - // will not touch this object again. + // At this point, we know that all threads executing DecrementCount + // will not touch this object again. // Therefore, the thread calling this method is free to delete the object // after we return from this method. } |