forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIWaitStrategy.h
More file actions
45 lines (35 loc) · 1.6 KB
/
IWaitStrategy.h
File metadata and controls
45 lines (35 loc) · 1.6 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
#pragma once
#include <cstdint>
#include <iosfwd>
#include <memory>
namespace Disruptor
{
class ISequence;
class ISequenceBarrier;
class Sequence;
class IWaitStrategy
{
public:
virtual ~IWaitStrategy() = default;
/**
* Wait for the given sequence to be available. It is possible for this method to return a value less than the sequence number supplied depending on the implementation of the WaitStrategy.
* A common use for this is to signal a timeout.Any EventProcessor that is using a WaitStrategy to get notifications about message becoming available should remember to handle this case.
* The BatchEventProcessor<T> explicitly handles this case and will signal a timeout if required.
*
* \param sequence sequence to be waited on.
* \param cursor Ring buffer cursor on which to wait.
* \param dependentSequence on which to wait.
* \param barrier barrier the IEventProcessor is waiting on.
* \returns the sequence that is available which may be greater than the requested sequence.
*/
virtual std::int64_t waitFor(std::int64_t sequence,
Sequence& cursor,
ISequence& dependentSequence,
ISequenceBarrier& barrier) = 0;
/**
* Signal those IEventProcessor waiting that the cursor has advanced.
*/
virtual void signalAllWhenBlocking() = 0;
virtual void writeDescriptionTo(std::ostream& stream) const = 0;
};
} // namespace Disruptor