-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJThread.cpp
More file actions
52 lines (37 loc) · 1.27 KB
/
JThread.cpp
File metadata and controls
52 lines (37 loc) · 1.27 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
// ===========================================================================
// JThread_01.cpp // class JThread
// ===========================================================================
#include "../Logger/Logger.h"
#include <format>
#include <iostream>
#include <thread>
namespace JoinableThread {
static void jthread_01()
{
std::thread t {
[] () { Logger::log(std::cout, "Inside std::thread"); }
};
bool joinable{ t.joinable() };
Logger::log(std::cout, "std::thread: joinable=", joinable);
t.join(); // <== put into comments -- must not be missing
}
static void jthread_02()
{
std::jthread t {
[] () { Logger::log(std::cout, "Inside std::jthread"); }
};
bool joinable{ t.joinable() };
Logger::log(std::cout, "std::jthread: joinable=", joinable);
t.join(); // <== put into comments -- may be missing
}
}
// =================================================================
void test_jthread()
{
using namespace JoinableThread;
jthread_01();
jthread_02();
}
// ===========================================================================
// End-of-File
// ===========================================================================