Line data Source code
1 : #ifndef THINGER_ASIO_WORKER_THREAD_HPP
2 : #define THINGER_ASIO_WORKER_THREAD_HPP
3 :
4 : #include <thread>
5 : #include "io_worker.hpp"
6 :
7 : namespace thinger::asio{
8 : class worker_thread {
9 : public:
10 : worker_thread(std::string worker_name = "");
11 : virtual ~worker_thread();
12 :
13 : void set_thread_name(std::string worker_name);
14 :
15 : boost::asio::io_context& get_io_context();
16 :
17 : std::thread::id start();
18 : bool stop();
19 : void run(std::function<void()> handler);
20 :
21 : protected:
22 22952 : virtual void async_worker(){};
23 :
24 : private:
25 : std::thread thread_;
26 : std::string worker_name_;
27 : io_worker worker_;
28 : };
29 : }
30 :
31 :
32 : #endif
|