forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventProcessorInfo.h
More file actions
79 lines (63 loc) · 2.04 KB
/
EventProcessorInfo.h
File metadata and controls
79 lines (63 loc) · 2.04 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
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
#pragma once
#include <memory>
#include "Disruptor/IConsumerInfo.h"
#include "Disruptor/IEventHandler.h"
#include "Disruptor/IEventProcessor.h"
namespace Disruptor
{
template <class T>
class EventProcessorInfo : public IConsumerInfo
{
public:
EventProcessorInfo(const std::shared_ptr< IEventProcessor >& eventProcessor,
const std::shared_ptr< IEventHandler< T > >& eventHandler,
const std::shared_ptr< ISequenceBarrier >& barrier)
: m_eventProcessor(eventProcessor)
, m_eventHandler(eventHandler)
, m_barrier(barrier)
, m_isEndOfChain(true)
{
}
const std::shared_ptr< IEventProcessor >& eventProcessor() const
{
return m_eventProcessor;
}
std::vector< std::shared_ptr< ISequence > > sequences() const override
{
return { m_eventProcessor->sequence() };
}
std::shared_ptr< IEventHandler< T > > handler() const
{
return m_eventHandler;
}
const std::shared_ptr< ISequenceBarrier >& barrier() const override
{
return m_barrier;
}
bool isEndOfChain() const override
{
return m_isEndOfChain;
}
void start(const std::shared_ptr< IExecutor >& executor) override
{
executor->execute([this]{ m_eventProcessor->run(); });
}
void halt() override
{
m_eventProcessor->halt();
}
void markAsUsedInBarrier() override
{
m_isEndOfChain = false;
}
bool isRunning() const override
{
return m_eventProcessor->isRunning();
}
private:
std::shared_ptr< IEventProcessor > m_eventProcessor;
std::shared_ptr< IEventHandler< T > > m_eventHandler;
std::shared_ptr< ISequenceBarrier > m_barrier;
bool m_isEndOfChain = true;
};
} // namespace Disruptor