CatapultServer  v0.5.0.1 (Elephant)
Task.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "Future.h"
24 #include <functional>
25 #include <string>
26 
27 namespace catapult { namespace thread {
28 
30  enum class TaskResult {
32  Continue,
33 
35  Break
36  };
37 
40 
43 
45  struct Task {
48 
51 
54 
56  std::string Name;
57  };
58 
61 
67  const utils::TimeSpan& minDelay,
68  uint32_t numPhaseOneRounds,
69  const utils::TimeSpan& maxDelay,
70  uint32_t numTransitionRounds);
71 
73  Task CreateNamedTask(const std::string& name, const TaskCallback& callback);
74 }}
catapult::thread::TaskCallback
supplier< thread::future< TaskResult > > TaskCallback
Task callback that is invoked by the scheduler.
Definition: Task.h:39
exceptions.h
Task.h
CATAPULT_THROW_INVALID_ARGUMENT_2
#define CATAPULT_THROW_INVALID_ARGUMENT_2(MESSAGE, PARAM1, PARAM2)
Macro used to throw a catapult invalid argument with two parameters.
Definition: exceptions.h:187
catapult::utils::TimeSpan::FromMilliseconds
static constexpr TimeSpan FromMilliseconds(uint64_t milliseconds)
Creates a time span from the given number of milliseconds.
Definition: TimeSpan.h:59
catapult::thread::DelayGenerator
supplier< utils::TimeSpan > DelayGenerator
Supplier that generates delays.
Definition: Task.h:42
catapult::utils::TimeSpan
Represents a time duration.
Definition: TimeSpan.h:30
catapult::thread::CreateUniformDelayGenerator
DelayGenerator CreateUniformDelayGenerator(const utils::TimeSpan &delay)
Creates a uniform delay generator that always returns delay.
Definition: Task.cpp:26
catapult::supplier
std::function< T()> supplier
A (stateless) supplier function.
Definition: functions.h:39
catapult::thread::CreateNamedTask
Task CreateNamedTask(const std::string &name, const TaskCallback &callback)
Creates an unscheduled task with name and callback.
Definition: Task.cpp:52
catapult::thread::TaskResult::Continue
Task should repeat.
catapult::thread::Task::Name
std::string Name
Friendly name of the task (optional).
Definition: Task.h:56
catapult::thread::TaskResult
TaskResult
Result of a task.
Definition: Task.h:30
catapult::thread::Task::NextDelay
DelayGenerator NextDelay
Generates the delay until the next execution of the task.
Definition: Task.h:50
catapult::thread::Task::Callback
TaskCallback Callback
Callback associated with the task.
Definition: Task.h:53
catapult::thread::Task::StartDelay
utils::TimeSpan StartDelay
Delay until the first execution of the task.
Definition: Task.h:47
TimeSpan.h
catapult::thread::TaskResult::Break
Task should not repeat.
catapult::thread::CreateIncreasingDelayGenerator
DelayGenerator CreateIncreasingDelayGenerator(const utils::TimeSpan &minDelay, uint32_t numPhaseOneRounds, const utils::TimeSpan &maxDelay, uint32_t numTransitionRounds)
Definition: Task.cpp:30
catapult
Definition: AddressExtractionExtension.cpp:28
Future.h
catapult::thread::Task
A task that can be dispatched to the scheduler.
Definition: Task.h:45