liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
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
/*
 * =====================================================================================
 *
 *       Filename:  io_service.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2021年05月27日 13时25分18秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Li Chao (), lichao@aiotlink.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include "io_service.h"
 
IoService::IoService() :
    guard_(io_.get_executor())
{
    std::thread([this]() { io_.run(); }).swap(worker_);
}
IoService::~IoService()
{
    guard_.reset();
    io_.stop(); // normally not needed, but make sure run() exits.
    if (worker_.joinable())
        worker_.join();
}