CatapultServer  v0.5.0.1 (Elephant)
DisruptorElement.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ConsumerInput.h"
24 
25 namespace catapult { namespace disruptor {
26 
29  public:
32  : m_id(static_cast<uint64_t>(-1))
33  , m_processingComplete([](auto, auto) {})
34  , m_pSpinLock(std::make_unique<utils::SpinLock>())
35  {}
36 
39  : m_input(std::move(input))
40  , m_id(id)
41  , m_processingComplete(processingComplete)
42  , m_pSpinLock(std::make_unique<utils::SpinLock>())
43  {}
44 
45  public:
48  return m_input;
49  }
50 
52  const ConsumerInput& input() const {
53  return m_input;
54  }
55 
58  return m_id;
59  }
60 
62  bool isSkipped() const {
65  }
66 
70  return m_result;
71  }
72 
73  public:
75  void markSkipped(PositionType position, CompletionCode code) {
78  m_result.CompletionCode = code;
80  }
81 
85  }
86 
87  private:
92  std::unique_ptr<utils::SpinLock> m_pSpinLock; // unique_ptr to allow moving of element
93  };
94 
96  std::ostream& operator<<(std::ostream& out, const DisruptorElement& element);
97 
99  constexpr bool IsIntervalElementId(DisruptorElementId id, size_t interval) {
100  return 0 != interval && 0 == id % interval;
101  }
102 }}
catapult::disruptor::ConsumerInput
Consumer input composed of a range of entities augmented with metadata.
Definition: ConsumerInput.h:30
SpinLock.h
catapult::disruptor::DisruptorElement::DisruptorElement
DisruptorElement()
Creates a default disruptor element.
Definition: DisruptorElement.h:31
catapult::disruptor::PositionType
uint64_t PositionType
Position within disruptor components.
Definition: DisruptorTypes.h:29
catapult::disruptor::DisruptorElement::m_pSpinLock
std::unique_ptr< utils::SpinLock > m_pSpinLock
Definition: DisruptorElement.h:92
catapult::disruptor::ConsumerCompletionResult
Extended consumer result passed to completion callback.
Definition: DisruptorTypes.h:105
catapult::disruptor::DisruptorElement::m_id
DisruptorElementId m_id
Definition: DisruptorElement.h:89
catapult::disruptor::ConsumerCompletionResult::FinalConsumerPosition
PositionType FinalConsumerPosition
Position of the final consumer processing the entity.
Definition: DisruptorTypes.h:113
catapult::disruptor::CompletionStatus::Aborted
Processing of the entity was aborted by a consumer.
catapult::disruptor::DisruptorElement
Augments consumer input with disruptor metadata.
Definition: DisruptorElement.h:28
catapult::disruptor::DisruptorElement::input
const ConsumerInput & input() const
Gets the consumer input.
Definition: DisruptorElement.h:52
catapult::disruptor::DisruptorElementId
uint64_t DisruptorElementId
Id of a disruptor element.
Definition: DisruptorTypes.h:32
catapult::disruptor::operator<<
std::ostream & operator<<(std::ostream &out, const ConsumerInput &input)
Definition: ConsumerInput.cpp:150
catapult::disruptor::DisruptorElement::input
ConsumerInput & input()
Gets the consumer input.
Definition: DisruptorElement.h:47
catapult::disruptor::DisruptorElement::completionResult
ConsumerCompletionResult completionResult() const
Gets the current element completion result.
Definition: DisruptorElement.h:68
catapult::disruptor::DisruptorElement::isSkipped
bool isSkipped() const
Returns true if the element is skipped.
Definition: DisruptorElement.h:62
ConsumerInput.h
catapult::disruptor::ProcessingCompleteFunc
consumer< DisruptorElementId, const ConsumerCompletionResult & > ProcessingCompleteFunc
Function signature for signaling that processing finished.
Definition: DisruptorTypes.h:117
catapult::disruptor::DisruptorElement::DisruptorElement
DisruptorElement(ConsumerInput &&input, DisruptorElementId id, const ProcessingCompleteFunc &processingComplete)
Creates a disruptor element around input with id and a completion handler processingComplete.
Definition: DisruptorElement.h:38
catapult::disruptor::DisruptorElement::m_input
ConsumerInput m_input
Definition: DisruptorElement.h:88
catapult::disruptor::ConsumerResult::CompletionCode
disruptor::CompletionCode CompletionCode
Optional code that can provide additional consumer completion information.
Definition: DisruptorTypes.h:80
catapult::disruptor::DisruptorElement::markSkipped
void markSkipped(PositionType position, CompletionCode code)
Marks the element as skipped at position with code.
Definition: DisruptorElement.h:75
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::disruptor::DisruptorElement::markProcessingComplete
void markProcessingComplete()
Calls the completion handler for the element.
Definition: DisruptorElement.h:83
catapult::disruptor::DisruptorElement::m_processingComplete
ProcessingCompleteFunc m_processingComplete
Definition: DisruptorElement.h:90
catapult::disruptor::IsIntervalElementId
constexpr bool IsIntervalElementId(DisruptorElementId id, size_t interval)
Returns true if id matches interval.
Definition: DisruptorElement.h:99
catapult::disruptor::DisruptorElement::id
DisruptorElementId id() const
Gets the element id.
Definition: DisruptorElement.h:57
catapult::disruptor::DisruptorElement::m_result
ConsumerCompletionResult m_result
Definition: DisruptorElement.h:91
catapult::utils::SpinLockGuard
std::lock_guard< SpinLock > SpinLockGuard
A spin lock guard.
Definition: SpinLock.h:60
DisruptorElement.h
catapult::disruptor::ConsumerResult::CompletionStatus
disruptor::CompletionStatus CompletionStatus
Completion status.
Definition: DisruptorTypes.h:77
catapult::disruptor::CompletionCode
uint32_t CompletionCode
Optional code that can provide additional consumer completion information.
Definition: DisruptorTypes.h:35