-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommon.cpp
More file actions
37 lines (32 loc) · 699 Bytes
/
Common.cpp
File metadata and controls
37 lines (32 loc) · 699 Bytes
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
#include <Common.h>
namespace Net
{
using boost::system::error_code;
Manager::Manager() : m_context{}, m_ioThread{}
{
std::promise<void> wait;
m_ioThread = std::thread([this, &wait]()
{
boost::asio::executor_work_guard work{m_context.get_executor()};
wait.set_value();
try
{
m_context.run();
}
catch (const error_code& error)
{
ioErrorOccured(error);
}
});
wait.get_future().get();
}
Manager::~Manager()
{
m_context.stop();
m_ioThread.join();
}
void Manager::ioErrorOccured([[maybe_unused]] const error_code& error)
{
[[maybe_unused]] std::string msg = error.message();
}
}