hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
thread_handler.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SUBSCRIPTION_THREAD_HANDLER_HPP
7 #define IROHA_SUBSCRIPTION_THREAD_HANDLER_HPP
8 
9 #include <assert.h>
10 #include <algorithm>
11 #include <chrono>
12 #include <deque>
13 #include <functional>
14 #include <mutex>
15 #include <shared_mutex>
16 #include <thread>
17 
18 #include "common/common.hpp"
20 
21 namespace iroha::subscription {
22 
23  class ThreadHandler final : public SchedulerBase {
24  private:
25  std::thread worker_;
26 
27  public:
29  worker_ = std::thread(
30  [](ThreadHandler *__this) { return __this->process(); }, this);
31  }
32 
33  void dispose(bool wait_for_release = true) {
34  SchedulerBase::dispose(wait_for_release);
35  if (wait_for_release)
36  worker_.join();
37  else
38  worker_.detach();
39  }
40  };
41 
42 } // namespace iroha::subscription
43 
44 #endif // IROHA_SUBSCRIPTION_THREAD_HANDLER_HPP
Definition: thread_handler.hpp:23
uint32_t process()
Definition: scheduler_impl.hpp:113
void dispose(bool wait_for_release=true)
Stops sheduler work and tasks execution.
Definition: thread_handler.hpp:33
Definition: scheduler_impl.hpp:30
Definition: subscription_fwd.hpp:60
void dispose(bool wait_for_release=true) override
Stops sheduler work and tasks execution.
Definition: scheduler_impl.hpp:134
ThreadHandler()
Definition: thread_handler.hpp:28