OSSIA
Open Scenario System for Interactive Application
network/context.hpp
1 #pragma once
3 
4 #include <boost/asio/executor_work_guard.hpp>
5 #include <boost/asio/io_context.hpp>
6 
7 #include <memory>
8 
9 namespace ossia::net
10 {
11 struct network_context
12 {
13  boost::asio::io_context context;
14 
15  void run()
16  {
17  auto wg = boost::asio::make_work_guard(context);
18 #if defined(__cpp_exceptions)
19  try
20  {
21  context.run();
22  }
23  catch(std::exception& e)
24  {
25  ossia::logger().error("Error while processing network events: {}", e.what());
26  }
27  catch(...)
28  {
29  ossia::logger().error("Error while processing network events.");
30  }
31 #else
32  context.run();
33 #endif
34  context.restart();
35  }
36 };
37 using network_context_ptr = std::shared_ptr<network_context>;
38 }
spdlog::logger & logger() noexcept
Where the errors will be logged. Default is stderr.
Definition: context.cpp:104