CatapultServer  v0.5.0.1 (Elephant)
Disruptor.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "DisruptorBarriers.h"
23 #include "DisruptorElement.h"
24 #include "catapult/model/Block.h"
28 #include <vector>
29 
30 namespace catapult { namespace disruptor {
31 
34  public:
37  explicit Disruptor(size_t disruptorSize, size_t elementTraceInterval = 1);
38 
39  public:
42  DisruptorElementId add(ConsumerInput&& input, const ProcessingCompleteFunc& processingComplete);
43 
45  void markSkipped(PositionType position, CompletionCode code);
46 
48  bool isSkipped(PositionType position) const;
49 
52  return m_container[position];
53  }
54 
56  inline size_t size() const {
57  return m_container.size();
58  }
59 
61  inline size_t capacity() const {
62  return m_container.capacity();
63  }
64 
66  inline uint64_t added() const {
67  return m_allElementsCount;
68  }
69 
70  private:
73  std::atomic<uint64_t> m_allElementsCount;
74  };
75 }}
Block.h
catapult::disruptor::ConsumerInput
Consumer input composed of a range of entities augmented with metadata.
Definition: ConsumerInput.h:30
catapult::disruptor::Disruptor::m_allElementsCount
std::atomic< uint64_t > m_allElementsCount
Definition: Disruptor.h:73
catapult::disruptor::Disruptor::Disruptor
Disruptor(size_t disruptorSize, size_t elementTraceInterval=1)
Definition: Disruptor.cpp:33
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
exceptions.h
catapult::disruptor::PositionType
uint64_t PositionType
Position within disruptor components.
Definition: DisruptorTypes.h:29
Parser.debug
def debug(*args)
Definition: Parser.py:46
catapult::disruptor::Disruptor::elementAt
DisruptorElement & elementAt(PositionType position)
Gets element at given position.
Definition: Disruptor.h:51
catapult::disruptor::Disruptor::isSkipped
bool isSkipped(PositionType position) const
Checks skip flag on the element at position.
Definition: Disruptor.cpp:52
catapult::disruptor::Disruptor::added
uint64_t added() const
Gets the number of total elements added to the disruptor.
Definition: Disruptor.h:66
catapult::disruptor::DisruptorElement
Augments consumer input with disruptor metadata.
Definition: DisruptorElement.h:28
CircularBuffer.h
Disruptor.h
catapult::utils::CircularBuffer
A fixed size circular buffer.
Definition: CircularBuffer.h:29
catapult::disruptor::Disruptor::m_container
utils::CircularBuffer< DisruptorElement > m_container
Definition: Disruptor.h:72
catapult::disruptor::DisruptorElementId
uint64_t DisruptorElementId
Id of a disruptor element.
Definition: DisruptorTypes.h:32
HexFormatter.h
Functional.h
catapult::disruptor::ProcessingCompleteFunc
consumer< DisruptorElementId, const ConsumerCompletionResult & > ProcessingCompleteFunc
Function signature for signaling that processing finished.
Definition: DisruptorTypes.h:117
EntityRange.h
catapult::disruptor::Disruptor::size
size_t size() const
Gets the size of the disruptor.
Definition: Disruptor.h:56
catapult::disruptor::Disruptor
Disruptor wraps around CircularBuffer for usage within Consumer Dispatcher.
Definition: Disruptor.h:33
catapult::disruptor::Disruptor::add
DisruptorElementId add(ConsumerInput &&input, const ProcessingCompleteFunc &processingComplete)
Definition: Disruptor.cpp:39
DisruptorBarriers.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::disruptor::Disruptor::m_elementTraceInterval
size_t m_elementTraceInterval
Definition: Disruptor.h:71
catapult::disruptor::IsIntervalElementId
constexpr bool IsIntervalElementId(DisruptorElementId id, size_t interval)
Returns true if id matches interval.
Definition: DisruptorElement.h:99
catapult::utils::NonCopyable
A class that can neither be copied nor moved.
Definition: NonCopyable.h:26
catapult::disruptor::Disruptor::capacity
size_t capacity() const
Gets the capacity of the disruptor.
Definition: Disruptor.h:61
DisruptorElement.h
catapult::disruptor::Disruptor::markSkipped
void markSkipped(PositionType position, CompletionCode code)
Sets skip flag on the element at position with code.
Definition: Disruptor.cpp:48
catapult::disruptor::CompletionCode
uint32_t CompletionCode
Optional code that can provide additional consumer completion information.
Definition: DisruptorTypes.h:35
NonCopyable.h