cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
sync_barrier.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <cstddef>
23#include <memory>
24
25namespace stat_bench {
26namespace util {
27
31class ISyncBarrier {
32public:
36 virtual void wait() = 0;
37
38 ISyncBarrier(const ISyncBarrier&) = delete;
39 ISyncBarrier(ISyncBarrier&&) = delete;
40 auto operator=(const ISyncBarrier&) = delete;
41 auto operator=(ISyncBarrier&&) = delete;
42
44 virtual ~ISyncBarrier() = default;
45
46protected:
48 ISyncBarrier() = default;
49};
50
59[[nodiscard]] auto create_mutex_sync_barrier(std::size_t num_waiting_threads)
60 -> std::shared_ptr<ISyncBarrier>;
61
68[[nodiscard]] auto create_sync_barrier(std::size_t num_waiting_threads)
69 -> std::shared_ptr<ISyncBarrier>;
70
71} // namespace util
72} // namespace stat_bench
virtual void wait()=0
Wait for other threads.
ISyncBarrier()=default
Constructor.
virtual ~ISyncBarrier()=default
Destructor.
Namespace of utility functions and classes.
auto create_mutex_sync_barrier(std::size_t num_waiting_threads) -> std::shared_ptr< ISyncBarrier >
Create a barrier to synchronize threads using a mutex.
auto create_sync_barrier(std::size_t num_waiting_threads) -> std::shared_ptr< ISyncBarrier >
Create a barrier to synchronize threads.
Namespace of stat_bench source codes.