valFuzz 1.2.0
Loading...
Searching...
No Matches
common.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#include <valfuzz/common.hpp>
7
8namespace valfuzz
9{
10
11std::mutex &get_stream_mutex()
12{
13#if __cplusplus >= 202002L // C++20
14 constinit
15#endif
16 static std::mutex stream_mutex;
17 return stream_mutex;
18}
19
20std::atomic<bool> &get_verbose()
21{
22#if __cplusplus >= 202002L // C++20
23 constinit
24#endif
25 static std::atomic<bool>
26 verbose = false;
27 return verbose;
28}
29
30std::atomic<long unsigned int> &get_max_num_threads()
31{
32#if __cplusplus >= 202002L // C++20
33 constinit
34#endif
35 static std::atomic<long unsigned int>
36 max_num_threads = 4;
37 return max_num_threads;
38}
39
40std::mutex &get_tests_mutex()
41{
42#if __cplusplus >= 202002L // C++20
43 constinit
44#endif
45 static std::mutex tests_mutex;
46 return tests_mutex;
47}
48
49std::atomic<bool> &get_is_threaded()
50{
51#if __cplusplus >= 202002L // C++20
52 constinit
53#endif
54 static std::atomic<bool>
55 is_threaded = true;
56 return is_threaded;
57}
58
59std::vector<std::thread> &get_thread_pool()
60{
61 static std::vector<std::thread> thread_pool;
62 return thread_pool;
63}
64
65} // namespace valfuzz
std::atomic< long unsigned int > & get_max_num_threads()
Definition common.cpp:30
std::vector< std::thread > & get_thread_pool()
Definition common.cpp:59
std::mutex & get_tests_mutex()
Definition common.cpp:40
std::atomic< bool > & get_verbose()
Definition common.cpp:20
std::atomic< bool > & get_is_threaded()
Definition common.cpp:49
std::mutex & get_stream_mutex()
Definition common.cpp:11