16 #ifndef BLOOMBERG_QUANTUM_SEQUENCER_H 17 #define BLOOMBERG_QUANTUM_SEQUENCER_H 19 #include <quantum/quantum_dispatcher.h> 20 #include <quantum/interface/quantum_ithread_context_base.h> 21 #include <quantum/util/quantum_sequencer_configuration.h> 22 #include <quantum/util/quantum_sequence_key_statistics.h> 24 #include <unordered_map> 39 template <
class SequenceKey,
40 class Hash = std::hash<SequenceKey>,
41 class KeyEqual = std::equal_to<SequenceKey>,
42 class Allocator = std::allocator<std::pair<const SequenceKey, SequenceKeyData>>>
67 template <
class FUNC,
class ... ARGS>
69 post(
const SequenceKey& sequenceKey, FUNC&& func, ARGS&&... args);
94 template <
class FUNC,
class ... ARGS>
96 post(
void* opaque,
int queueId,
bool isHighPriority,
const SequenceKey& sequenceKey, FUNC&& func, ARGS&&... args);
111 template <
class FUNC,
class ... ARGS>
113 post(
const std::vector<SequenceKey>& sequenceKeys, FUNC&& func, ARGS&&... args);
138 template <
class FUNC,
class ... ARGS>
143 const std::vector<SequenceKey>& sequenceKeys,
159 template <
class FUNC,
class ... ARGS>
161 postAll(FUNC&& func, ARGS&&... args);
185 template <
class FUNC,
class ... ARGS>
187 postAll(
void* opaque,
int queueId,
bool isHighPriority, FUNC&& func, ARGS&&... args);
219 using ContextMap = std::unordered_map<SequenceKey, SequenceKeyData, Hash, KeyEqual, Allocator>;
222 template <
class FUNC,
class ... ARGS>
230 template <
class FUNC,
class ... ARGS>
234 std::vector<SequenceKeyData>&& dependents,
238 template <
class FUNC,
class ... ARGS>
242 std::vector<SequenceKeyData>&& dependents,
246 template <
class FUNC,
class ... ARGS>
247 static int singleSequenceKeyTaskScheduler(
253 SequenceKey&& sequenceKey,
256 template <
class FUNC,
class ... ARGS>
257 static int multiSequenceKeyTaskScheduler(
263 std::vector<SequenceKey>&& sequenceKeys,
266 template <
class FUNC,
class ... ARGS>
267 static int universalTaskScheduler(
275 template <
class FUNC,
class ... ARGS>
288 int _controllerQueueId;
290 ContextMap _contexts;
291 ExceptionCallback _exceptionCallback;
292 std::shared_ptr<SequenceKeyStatisticsWriter> _taskStats;
297 #include <quantum/util/impl/quantum_sequencer_impl.h> 299 #endif //BLOOMBERG_QUANTUM_SEQUENCER_H Sequencer(Dispatcher &dispatcher, const Configuration &configuration=Configuration())
Constructor.
Definition: quantum_sequencer_impl.h:28
SequenceKeyStatistics getTaskStatistics()
Gets the sequencer statistics for all jobs.
Definition: quantum_sequencer_impl.h:226
Definition: quantum_buffer_impl.h:22
SequenceKeyStatistics getStatistics()
Gets the sequencer statistics for the 'universal key', a.k.a. posted via postAll() method.
Definition: quantum_sequencer_impl.h:219
size_t trimSequenceKeys()
Trims the sequence keys not used by the sequencer anymore.
Definition: quantum_sequencer_impl.h:184
void post(const SequenceKey &sequenceKey, FUNC &&func, ARGS &&... args)
Post a coroutine to run asynchronously.
Definition: quantum_sequencer_impl.h:49
typename ICoroContext< RET >::Ptr CoroContextPtr
Definition: quantum_icoro_context.h:479
Implementation of a configuration class for Sequencer.
Definition: quantum_sequencer_configuration.h:41
ICoroContextBase::Ptr ICoroContextBasePtr
Definition: quantum_icoro_context_base.h:79
Parallel execution engine used to run coroutines or IO tasks asynchronously. This class is the main e...
Definition: quantum_dispatcher.h:34
Implementation of a statistics collection for a SequenceKey in Sequencer.
Definition: quantum_sequence_key_statistics.h:32
Definition: quantum_sequencer_configuration_impl.h:28
std::function< void(std::exception_ptr exception, void *opaque)> ExceptionCallback
Callback for unhandled exceptions in tasks posted to Sequencer.
Definition: quantum_sequencer_configuration.h:48
size_t getSequenceKeyCount()
Gets the number of tracked sequence keys.
Definition: quantum_sequencer_impl.h:233
SequencerConfiguration< SequenceKey, Hash, KeyEqual, Allocator > Configuration
Configuration class for Sequencer.
Definition: quantum_sequencer.h:47
void postAll(FUNC &&func, ARGS &&... args)
Post a coroutine to run asynchronously.
Definition: quantum_sequencer_impl.h:144
Implementation of a key-based task sequencing with quantum.
Definition: quantum_sequencer.h:43