YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
util.cpp
Go to the documentation of this file.
1#include <fault/util.hpp>
2
3namespace yaclib::detail {
4
5static std::uint32_t sSeed = 1239;
6
7#if YACLIB_FAULT == 2
8static std::uint64_t sRandCount = 0;
9#endif
10
11static thread_local std::mt19937_64 eng{sSeed};
12
13void SetSeed(std::uint32_t new_seed) {
15 eng.seed(new_seed);
16}
17
18std::uint32_t GetSeed() {
19 return sSeed;
20}
21
22std::uint64_t GetRandNumber(std::uint64_t max) {
23#if YACLIB_FAULT == 2
24 sRandCount++;
25#endif
26 return eng() % max;
27}
28
29std::uint64_t GetRandCount() {
30#if YACLIB_FAULT == 2
31 return sRandCount;
32#else
33 return 0;
34#endif
35}
36
38#if YACLIB_FAULT == 2
39 for (std::uint64_t i = 0; i != random_count; ++i) {
41 }
42#endif
43}
44
45} // namespace yaclib::detail
static thread_local std::mt19937_64 eng
Definition util.cpp:11
std::uint64_t GetRandNumber(std::uint64_t max)
Definition util.cpp:22
static std::uint32_t sSeed
Definition util.cpp:5
void SetSeed(std::uint32_t new_seed)
Definition util.cpp:13
std::uint32_t GetSeed()
Definition util.cpp:18
std::uint64_t GetRandCount()
Definition util.cpp:29
void ForwardToRandCount(std::uint64_t random_count)
Definition util.cpp:37
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25