forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionEventHandler.cpp
More file actions
54 lines (44 loc) · 1.25 KB
/
Copy pathFunctionEventHandler.cpp
File metadata and controls
54 lines (44 loc) · 1.25 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
#include "stdafx.h"
#include "FunctionEventHandler.h"
namespace Disruptor
{
namespace PerfTests
{
FunctionEventHandler::FunctionEventHandler(FunctionStep functionStep)
: m_functionStep(functionStep)
{
}
std::int64_t FunctionEventHandler::stepThreeCounter() const
{
return m_counter.value;
}
void FunctionEventHandler::reset(const std::shared_ptr< Tests::ManualResetEvent >& latch, std::int64_t iterations)
{
m_counter.value = 0;
m_iterations = iterations;
m_latch = latch;
}
void FunctionEventHandler::onEvent(FunctionEvent& data, std::int64_t sequence, bool /*endOfBatch*/)
{
switch (m_functionStep)
{
case FunctionStep::One:
data.stepOneResult = data.operandOne + data.operandTwo;
break;
case FunctionStep::Two:
data.stepTwoResult = data.stepOneResult + 3L;
break;
case FunctionStep::Three:
if ((data.stepTwoResult & 4L) == 4L)
{
m_counter.value = m_counter.value + 1;
}
break;
}
if (sequence == m_iterations - 1)
{
m_latch->set();
}
}
} // namespace PerfTests
} // namespace Disruptor