CatapultServer  v0.5.0.1 (Elephant)
Scheduler.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "Task.h"
23 #include <string>
24 
25 namespace catapult { namespace thread { class IoThreadPool; } }
26 
27 namespace catapult { namespace thread {
28 
30  class Scheduler {
31  public:
32  virtual ~Scheduler() = default;
33 
34  public:
36  virtual uint32_t numScheduledTasks() const = 0;
37 
39  virtual uint32_t numExecutingTaskCallbacks() const = 0;
40 
41  public:
43  virtual void addTask(const Task& task) = 0;
44 
46  virtual void shutdown() = 0;
47  };
48 
50  std::shared_ptr<Scheduler> CreateScheduler(const std::shared_ptr<IoThreadPool>& pPool);
51 }}
CATAPULT_THROW_EXCEPTION
#define CATAPULT_THROW_EXCEPTION(EXCEPTION)
Macro used to throw a catapult exception.
Definition: exceptions.h:142
FutureUtils.h
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
exceptions.h
m_numExecutingTaskCallbacks
std::atomic< uint32_t > m_numExecutingTaskCallbacks
Definition: Scheduler.cpp:207
m_tasks
utils::WeakContainer< StrandedTaskWrapper > m_tasks
Definition: Scheduler.cpp:209
m_ioContext
boost::asio::io_context & m_ioContext
Definition: Scheduler.cpp:205
Parser.debug
def debug(*args)
Definition: Parser.py:46
Task.h
catapult::thread::Scheduler::addTask
virtual void addTask(const Task &task)=0
Adds a scheduled task to the scheduler.
m_strandWrapper
StrandOwnerLifetimeExtender< StrandedTaskWrapper > m_strandWrapper
Definition: Scheduler.cpp:144
colorPrint.warning
def warning(*args)
Definition: colorPrint.py:10
catapult::thread::compose
auto compose(future< TSeed > &&startFuture, TCreateNextFuture createNextFuture)
Definition: FutureUtils.h:102
m_task
Task m_task
Definition: Scheduler.cpp:94
catapult::thread::Scheduler::~Scheduler
virtual ~Scheduler()=default
m_impl
BasicTaskWrapper< StrandedTaskWrapper > m_impl
Definition: Scheduler.cpp:145
catapult::thread::Scheduler
A scheduler.
Definition: Scheduler.h:30
catapult::thread::Scheduler::shutdown
virtual void shutdown()=0
Shuts down the scheduler.
catapult::thread::Scheduler::numScheduledTasks
virtual uint32_t numScheduledTasks() const =0
Gets the number of tasks that are currently either scheduled or executing.
m_isStopped
bool m_isStopped
Definition: Scheduler.cpp:97
catapult::sync::Scheduler
DECLARE_SERVICE_REGISTRAR() Scheduler(const TasksConfiguration &config)
Definition: SchedulerService.cpp:86
IoThreadPool.h
forwardsValidation.info
def info(*args)
Definition: forwardsValidation.py:12
catapult::thread::Scheduler::numExecutingTaskCallbacks
virtual uint32_t numExecutingTaskCallbacks() const =0
Gets the number of currently executing task callbacks.
Scheduler.h
catapult::thread::TaskResult
TaskResult
Result of a task.
Definition: Task.h:30
CATAPULT_THROW_RUNTIME_ERROR
#define CATAPULT_THROW_RUNTIME_ERROR(MESSAGE)
Macro used to throw a catapult runtime error.
Definition: exceptions.h:167
catapult::thread::TaskResult::Break
Task should not repeat.
catapult
Definition: AddressExtractionExtension.cpp:28
Logging.h
m_strand
boost::asio::io_context::strand m_strand
Definition: Scheduler.cpp:143
catapult::thread::CreateScheduler
std::shared_ptr< Scheduler > CreateScheduler(const std::shared_ptr< IoThreadPool > &pPool)
Creates a scheduler around the specified thread pool (pPool).
Definition: Scheduler.cpp:213
m_wrapper
TCallbackWrapper & m_wrapper
Definition: Scheduler.cpp:95
m_pPool
std::shared_ptr< const IoThreadPool > m_pPool
Definition: Scheduler.cpp:204
WeakContainer.h
m_timer
boost::asio::steady_timer m_timer
Definition: Scheduler.cpp:96
catapult::thread::Task
A task that can be dispatched to the scheduler.
Definition: Task.h:45
StrandOwnerLifetimeExtender.h