/Users/deen/code/yugabyte-db/src/yb/util/test_thread_holder.cc
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #include "yb/util/test_thread_holder.h" |
15 | | |
16 | | namespace yb { |
17 | | |
18 | 48 | void TestThreadHolder::JoinAll() { |
19 | 48 | LOG(INFO) << __func__; |
20 | | |
21 | 276 | for (auto& thread : threads_) { |
22 | 276 | if (thread.joinable()) { |
23 | 142 | thread.join(); |
24 | 142 | } |
25 | 276 | } |
26 | | |
27 | 48 | LOG(INFO) << __func__ << " done"; |
28 | 48 | } |
29 | | |
30 | 10 | void WaitStopped(const CoarseDuration& duration, std::atomic<bool>* stop) { |
31 | 10 | auto end = CoarseMonoClock::now() + duration; |
32 | 1.62k | while (!stop->load(std::memory_order_acquire) && CoarseMonoClock::now() < end1.61k ) { |
33 | 1.61k | std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
34 | 1.61k | } |
35 | 10 | } |
36 | | |
37 | | } // namespace yb |