lichao
2021-06-23 c1e39e20ca42b21eeac8b5068fa1f921bf9a070f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * =====================================================================================
 *
 *       Filename:  io_service.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2021年05月27日 13时25分37秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Li Chao (), lichao@aiotlink.com
 *   Organization:  
 *
 * =====================================================================================
 */
#ifndef IO_SERVICE_ODKKJG3D
#define IO_SERVICE_ODKKJG3D
 
#include <boost/asio.hpp>
#include <thread>
 
class IoService
{
public:
    IoService();
    ~IoService();
 
    typedef boost::asio::io_context io_service_t;
    io_service_t &io() { return io_; }
 
private:
    io_service_t io_;
    typedef boost::asio::executor_work_guard<io_service_t::executor_type> guard_t;
    guard_t guard_;
    std::thread worker_;
};
 
#endif // end of include guard: IO_SERVICE_ODKKJG3D