diff options
author | Abseil Team <absl-team@google.com> | 2018-01-18T20·42-0800 |
---|---|---|
committer | vslashg <gfalcon@google.com> | 2018-01-18T21·14-0500 |
commit | 52a2458965fc2ef6f03fb692b253a1ca56ff6e39 (patch) | |
tree | 9a954f4a03f9ac08db891baf5f39b29f5c0d7d23 /absl/synchronization | |
parent | 5a8de8a37e3e282d22f69ca67b4aba8e4cca63ae (diff) |
Changes imported from Abseil "staging" branch:
- 3f758237a43af1f277990492701d26d1153b4d74 Generalize the construction/destruction tests, to prepare... by Greg Falcon <gfalcon@google.com> - 7bea88f74fbac34b0c0b00b8b832a544988b9465 Simplify non intrinsic uint128 multiply. by Alex Strelnikov <strel@google.com> GitOrigin-RevId: 3f758237a43af1f277990492701d26d1153b4d74 Change-Id: Idd9a2df0b90403f10f56bb66d30b76a8ba9f50e7
Diffstat (limited to 'absl/synchronization')
-rw-r--r-- | absl/synchronization/lifetime_test.cc | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/absl/synchronization/lifetime_test.cc b/absl/synchronization/lifetime_test.cc index a3e2701f9208..90c9009b18fa 100644 --- a/absl/synchronization/lifetime_test.cc +++ b/absl/synchronization/lifetime_test.cc @@ -18,6 +18,7 @@ #include "absl/base/attributes.h" #include "absl/base/internal/raw_logging.h" +#include "absl/base/thread_annotations.h" #include "absl/synchronization/mutex.h" #include "absl/synchronization/notification.h" @@ -106,24 +107,19 @@ void TestLocals() { // definitions. We can use this to arrange for tests to be run on these objects // before they are created, and after they are destroyed. -class ConstructorTestRunner { +using Function = void (*)(); + +class OnConstruction { public: - ConstructorTestRunner(absl::Mutex* mutex, absl::CondVar* condvar, - absl::Notification* notification) { - RunTests(mutex, condvar, notification); - } + explicit OnConstruction(Function fn) { fn(); } }; -class DestructorTestRunner { +class OnDestruction { public: - DestructorTestRunner(absl::Mutex* mutex, absl::CondVar* condvar, - absl::Notification* notification) - : mutex_(mutex), condvar_(condvar), notification_(notification) {} - ~DestructorTestRunner() { RunTests(mutex_, condvar_, notification_); } + explicit OnDestruction(Function fn) : fn_(fn) {} + ~OnDestruction() { fn_(); } private: - absl::Mutex* mutex_; - absl::CondVar* condvar_; - absl::Notification* notification_; + Function fn_; }; } // namespace |