hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
dispatcher.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SUBSCRIPTION_DISPATCHER_HPP
7 #define IROHA_SUBSCRIPTION_DISPATCHER_HPP
8 
9 #include <optional>
10 
11 #include "common/common.hpp"
13 
14 namespace iroha::subscription {
15 
16  struct IDispatcher {
17  using Tid = uint32_t;
19  static constexpr Tid kExecuteInPool = std::numeric_limits<Tid>::max();
20 
21  virtual ~IDispatcher() {}
22 
23  virtual std::optional<Tid> bind(std::shared_ptr<IScheduler> scheduler) = 0;
24  virtual bool unbind(Tid tid) = 0;
25 
26  virtual void dispose() = 0;
27  virtual void add(Tid tid, Task &&task) = 0;
28  virtual void addDelayed(Tid tid,
29  std::chrono::microseconds timeout,
30  Task &&task) = 0;
31  };
32 
33 } // namespace iroha::subscription
34 
35 #endif // IROHA_SUBSCRIPTION_DISPATCHER_HPP
Definition: dispatcher.hpp:16
virtual bool unbind(Tid tid)=0
uint32_t Tid
Definition: dispatcher.hpp:17
virtual std::optional< Tid > bind(std::shared_ptr< IScheduler > scheduler)=0
Definition: subscription_fwd.hpp:60
virtual ~IDispatcher()
Definition: dispatcher.hpp:21
static constexpr Tid kExecuteInPool
Definition: dispatcher.hpp:19
virtual void addDelayed(Tid tid, std::chrono::microseconds timeout, Task &&task)=0
virtual void add(Tid tid, Task &&task)=0
std::function< void()> Task
Definition: scheduler.hpp:17
IScheduler::Task Task
Definition: dispatcher.hpp:18