hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
sync_dispatcher_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SUBSCRIPTION_SYNC_DISPATCHER_IMPL_HPP
7 #define IROHA_SUBSCRIPTION_SYNC_DISPATCHER_IMPL_HPP
8 
10 
11 #include "common/common.hpp"
13 
14 namespace iroha::subscription {
15 
16  template <uint32_t kCount, uint32_t kPoolSize>
17  class SyncDispatcher final : public IDispatcher,
20  private:
21  using Parent = IDispatcher;
22 
23  public:
24  SyncDispatcher() = default;
25 
26  void dispose() override {}
27 
28  void add(typename Parent::Tid /*tid*/,
29  typename Parent::Task &&task) override {
30  task();
31  }
32 
33  void addDelayed(typename Parent::Tid /*tid*/,
34  std::chrono::microseconds /*timeout*/,
35  typename Parent::Task &&task) override {
36  task();
37  }
38 
39  std::optional<Tid> bind(std::shared_ptr<IScheduler> scheduler) override {
40  if (!scheduler)
41  return std::nullopt;
42 
43  return kCount;
44  }
45 
46  bool unbind(Tid tid) override {
47  return tid == kCount;
48  }
49  };
50 
51 } // namespace iroha::subscription
52 
53 #endif // IROHA_SUBSCRIPTION_SYNC_DISPATCHER_IMPL_HPP
Definition: dispatcher.hpp:16
uint32_t Tid
Definition: dispatcher.hpp:17
Definition: common.hpp:26
Definition: subscription_fwd.hpp:60
Definition: sync_dispatcher_impl.hpp:17
bool unbind(Tid tid) override
Definition: sync_dispatcher_impl.hpp:46
void add(typename Parent::Tid, typename Parent::Task &&task) override
Definition: sync_dispatcher_impl.hpp:28
std::optional< Tid > bind(std::shared_ptr< IScheduler > scheduler) override
Definition: sync_dispatcher_impl.hpp:39
void dispose() override
Definition: sync_dispatcher_impl.hpp:26
void addDelayed(typename Parent::Tid, std::chrono::microseconds, typename Parent::Task &&task) override
Definition: sync_dispatcher_impl.hpp:33
IScheduler::Task Task
Definition: dispatcher.hpp:18
Definition: common.hpp:32