forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValueAdditionEventHandler.cpp
More file actions
39 lines (31 loc) · 857 Bytes
/
Copy pathValueAdditionEventHandler.cpp
File metadata and controls
39 lines (31 loc) · 857 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
#include "stdafx.h"
#include "ValueAdditionEventHandler.h"
namespace Disruptor
{
namespace PerfTests
{
void ValueAdditionEventHandler::reset(const std::shared_ptr< Tests::ManualResetEvent >& latch, std::int64_t expectedCount)
{
m_value.value = 0;
m_latch = latch;
m_count = expectedCount;
}
void ValueAdditionEventHandler::onEvent(ValueEvent& value, std::int64_t sequence, bool)
{
m_value.value = m_value.value + value.value;
if (count() == sequence)
{
if (m_latch != nullptr)
m_latch->set();
}
}
std::int64_t ValueAdditionEventHandler::count() const
{
return m_count;
}
std::int64_t ValueAdditionEventHandler::value() const
{
return m_value.value;
}
} // namespace PerfTests
} // namespace Disruptor