-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
37 lines (30 loc) · 701 Bytes
/
test.cpp
File metadata and controls
37 lines (30 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "lum/log.hpp"
#include "lum/lum.hpp"
#include <cassert>
#include <mutex>
#include <set>
#include <stdexcept>
#include <thread>
void test(std::set<int> &values) {
int value{0};
lum::mutex mutex;
std::thread t{[&] {
std::unique_lock<lum::mutex> lock{mutex};
value = 42;
}};
{
std::unique_lock<lum::mutex> lock{mutex};
std::cerr << "value: " << value << std::endl;
values.insert(value);
}
t.join();
}
int main() {
// Boilerplate which ought to end up somewhere in the lib itself.
lum::mutator &mutator = lum::global_mutator();
std::set<int> values;
do {
test(values);
} while (mutator.next());
assert((values == std::set<int>{0, 42}));
}