forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSequenceUpdater.cpp
More file actions
43 lines (37 loc) · 984 Bytes
/
SequenceUpdater.cpp
File metadata and controls
43 lines (37 loc) · 984 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
38
39
40
41
42
43
#include "stdafx.h"
#include "SequenceUpdater.h"
namespace Disruptor
{
namespace Tests
{
SequenceUpdater::SequenceUpdater(std::int64_t sleepTime, const std::shared_ptr< IWaitStrategy >& waitStrategy)
: m_barrier(2)
, m_sleepTime(static_cast< std::int32_t >(sleepTime))
, m_waitStrategy(waitStrategy)
{
}
void SequenceUpdater::run()
{
try
{
m_barrier.signal();
m_barrier.wait();
if (0 != m_sleepTime)
{
std::this_thread::sleep_for(std::chrono::milliseconds(m_sleepTime));
}
sequence->incrementAndGet();
m_waitStrategy->signalAllWhenBlocking();
}
catch (std::exception& ex)
{
std::cout << ex.what() << std::endl;
}
}
void SequenceUpdater::waitForStartup()
{
m_barrier.signal();
m_barrier.wait();
}
} // namespace Tests
} // namespace Disruptor