forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISequence.h
More file actions
53 lines (42 loc) · 1.55 KB
/
ISequence.h
File metadata and controls
53 lines (42 loc) · 1.55 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
#pragma once
#include <cstdint>
#include <iosfwd>
namespace Disruptor
{
class ISequence
{
public:
virtual ~ISequence() = default;
/**
* Current sequence number
*/
virtual std::int64_t value() const = 0;
/**
* Perform an ordered write of this sequence. The intent isa Store/Store barrier between this write and any previous store.
*
* \param value The new value for the sequence.
*/
virtual void setValue(std::int64_t value) = 0;
/**
* Atomically set the value to the given updated value if the current value == the expected value.
*
* \param expectedSequence the expected value for the sequence
* \param nextSequence the new value for the sequence
* \returns true if successful. False return indicates that the actual value was not equal to the expected value.
*/
virtual bool compareAndSet(std::int64_t expectedSequence, std::int64_t nextSequence) = 0;
/**
* Increments the sequence and stores the result, as an atomic operation.
*
* \returns incremented sequence
*/
virtual std::int64_t incrementAndGet() = 0;
/**
* Increments the sequence and stores the result, as an atomic operation.
*
* \returns incremented sequence
*/
virtual std::int64_t addAndGet(std::int64_t value) = 0;
virtual void writeDescriptionTo(std::ostream& stream) const = 0;
};
} // namespace Disruptor