/*
|
* =====================================================================================
|
*
|
* 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();
|
}
|