-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfail_thread_runner.cpp
More file actions
55 lines (46 loc) · 1.52 KB
/
fail_thread_runner.cpp
File metadata and controls
55 lines (46 loc) · 1.52 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <functional>
#include <memory>
#include <print>
#include <scl/safe_thread.h>
using namespace std::literals;
template <typename T>
struct is_send_test : std::integral_constant<
bool,
(! (std::is_lvalue_reference_v<T>
|| scl::is_lambda_v<T>))
&&
(std::is_pod_v<T>
|| std::is_move_constructible_v<T>
|| (scl::is_function_pointer_v<std::decay_t<T>>
&& ! std::is_member_function_pointer_v<T>)
|| scl::is_sync_v<T>)>
{};
template<typename T> struct is_send_test<T*> : std::false_type {};
template<typename T> struct is_send_test<const T*> : std::false_type {};
template<typename T> struct is_send_test<T*&> : std::false_type {};
template<typename T> struct is_send_test<T*&&> : std::false_type {};
template<typename T> struct is_send_test<const T*&> : std::false_type {};
template<typename T> struct is_send_test<const T*&&> : std::false_type {};
template<typename T>
void check (T&&) {
static_assert (! is_send_test<T>::value);
}
class thread_runner
{
public:
thread_runner()
{
thread = std::make_unique<scl::thread> (std::mem_fn (&thread_runner::run), this);
}
private:
std::unique_ptr<scl::thread> thread;
void run() const
{
std::println("PROCESSING...");
std::this_thread::sleep_for (1s);
std::println("...DONE");
}
};
int main() {
thread_runner r;
}