forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLongArrayEventHandler.cpp
More file actions
47 lines (38 loc) · 1.05 KB
/
Copy pathLongArrayEventHandler.cpp
File metadata and controls
47 lines (38 loc) · 1.05 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
#include "stdafx.h"
#include "LongArrayEventHandler.h"
namespace Disruptor
{
namespace PerfTests
{
std::int64_t LongArrayEventHandler::count() const
{
return m_count;
}
const std::shared_ptr< Tests::ManualResetEvent >& LongArrayEventHandler::signal() const
{
return m_signal;
}
std::int64_t LongArrayEventHandler::value() const
{
return m_value->value;
}
void LongArrayEventHandler::reset(const std::shared_ptr< Tests::ManualResetEvent >& signal, std::int64_t expectedCount)
{
m_value->value = 0L;
m_signal = signal;
m_count = expectedCount;
}
void LongArrayEventHandler::onEvent(std::vector< std::int64_t >& data, std::int64_t /*sequence*/, bool /*endOfBatch*/)
{
for (auto i = 0u; i < data.size(); ++i)
{
m_value->value = m_value->value + data[i];
}
if (--m_count == 0)
{
if (m_signal != nullptr)
m_signal->set();
}
}
} // namespace PerfTests
} // namespace Disruptor