YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/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
19
void TestThreadHolder::JoinAll() {
19
19
  LOG(INFO) << __func__;
20
21
134
  for (auto& thread : threads_) {
22
134
    if (thread.joinable()) {
23
70
      thread.join();
24
70
    }
25
134
  }
26
27
19
  LOG(INFO) << __func__ << " done";
28
19
}
29
30
6
void WaitStopped(const CoarseDuration& duration, std::atomic<bool>* stop) {
31
6
  auto end = CoarseMonoClock::now() + duration;
32
635
  while (!stop->load(std::memory_order_acquire) && CoarseMonoClock::now() < end) {
33
629
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
34
629
  }
35
6
}
36
37
}  // namespace yb