FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Disruptor-cpp/Disruptor.TestTools/ResetEvent.cpp at master · githubCode3a/Disruptor-cpp · GitHub
githubCode3a
/
Disruptor-cpp
Public
forked from
Abc-Arbitrage/Disruptor-cpp
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Disruptor-cpp
/
Disruptor.TestTools
/
ResetEvent.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
79 lines (63 loc) · 1.74 KB
Breadcrumbs
Disruptor-cpp
/
Disruptor.TestTools
/
ResetEvent.cpp
Copy path
File metadata and controls
79 lines (63 loc) · 1.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#
include
"
stdafx.h
"
#
include
"
ResetEvent.h
"
namespace
Disruptor
{
namespace
Tests
{
ResetEvent::ResetEvent
(
bool
signaled)
: m_signaled(signaled)
, m_mutex()
, m_conditionVariable()
, m_waitCount(
0
)
{
}
void
ResetEvent::set
(
bool
ensureWaitIsTriggered)
{
{
std::unique_lock<
decltype
(m_mutex) >
lock
(m_mutex);
m_signaled =
true
;
}
m_conditionVariable.
notify_all
();
while
(ensureWaitIsTriggered && m_waitCount >
0
)
std::this_thread::yield
();
}
void
ResetEvent::reset
()
{
std::unique_lock<
decltype
(m_mutex) >
lock
(m_mutex);
m_signaled =
false
;
}
bool
ResetEvent::internalWait
(ClockConfig::Duration timeDuration)
{
std::unique_lock<
decltype
(m_mutex) >
lock
(m_mutex);
auto
hasReceivedSignal =
false
;
if
(!m_signaled)
{
++m_waitCount;
if
(timeDuration ==
ClockConfig::Duration
())
{
do
{
m_conditionVariable.
wait
(lock);
}
while
(!m_signaled);
hasReceivedSignal =
true
;
}
else
{
hasReceivedSignal = m_conditionVariable.
wait_for
(lock, timeDuration, [
this
] {
return
this
->
m_signaled
; });
}
--m_waitCount;
}
return
hasReceivedSignal || m_signaled;
}
bool
ResetEvent::wait
(ClockConfig::Duration timeDuration)
{
return
internalWait
(timeDuration);
}
bool
ResetEvent::isSet
()
const
{
std::lock_guard<
decltype
(m_mutex) >
lock
(m_mutex);
return
m_signaled;
}
}
//
namespace Tests
}
//
namespace Disruptor
Back
|
FazBrowse Home
|
New Git URL