CppCommon
1.0.5.0
C++ Common Library
Loading...
Searching...
No Matches
include
threads
thread.inl
Go to the documentation of this file.
1
9
namespace
CppCommon
{
10
11
template
<
class
TOutputStream>
12
inline
TOutputStream&
operator<<
(TOutputStream& stream,
ThreadPriority
priority)
13
{
14
switch
(priority)
15
{
16
case
ThreadPriority::IDLE
:
17
stream <<
"IDLE"
;
18
break
;
19
case
ThreadPriority::LOWEST
:
20
stream <<
"LOWEST"
;
21
break
;
22
case
ThreadPriority::LOW
:
23
stream <<
"LOW"
;
24
break
;
25
case
ThreadPriority::NORMAL
:
26
stream <<
"NORMAL"
;
27
break
;
28
case
ThreadPriority::HIGH
:
29
stream <<
"HIGH"
;
30
break
;
31
case
ThreadPriority::HIGHEST
:
32
stream <<
"HIGHEST"
;
33
break
;
34
case
ThreadPriority::REALTIME
:
35
stream <<
"REALTIME"
;
36
break
;
37
default
:
38
stream <<
"<unknown>"
;
39
break
;
40
}
41
return
stream;
42
}
43
44
template
<
class
Fn,
class
... Args>
45
inline
std::thread
Thread::Start
(Fn&& fn, Args&&... args)
46
{
47
return
std::thread([fn = fn, args...]()
48
{
49
// Setup exception handler for the new thread
50
ExceptionsHandler::SetupThread();
51
52
// Call the base thread function
53
fn(std::move(args)...);
54
});
55
}
56
57
}
// namespace CppCommon
CppCommon::Thread::Start
static std::thread Start(Fn &&fn, Args &&... args)
Start a new thread with an exception handler registered.
Definition
thread.inl:45
CppCommon
C++ Common project definitions.
Definition
token_bucket.h:15
CppCommon::operator<<
std::ostream & operator<<(std::ostream &os, const uint128_t &value)
Definition
uint128.inl:155
CppCommon::ThreadPriority
ThreadPriority
Thread priorities.
Definition
thread.h:28
CppCommon::ThreadPriority::NORMAL
@ NORMAL
Normal thread priority.
CppCommon::ThreadPriority::LOW
@ LOW
Low thread priority.
CppCommon::ThreadPriority::REALTIME
@ REALTIME
Realtime thread priority.
CppCommon::ThreadPriority::LOWEST
@ LOWEST
Lowest thread priority.
CppCommon::ThreadPriority::IDLE
@ IDLE
Idle thread priority.
CppCommon::ThreadPriority::HIGH
@ HIGH
High thread priority.
CppCommon::ThreadPriority::HIGHEST
@ HIGHEST
Highest thread priority.
Generated by
1.9.8