init
This commit is contained in:
commit
5962730120
11 changed files with 354 additions and 0 deletions
26
include/network.h
Normal file
26
include/network.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/co_spawn.hpp>
|
||||
#include <boost/asio/executor_work_guard.hpp>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
namespace asio = boost::asio;
|
||||
|
||||
class NetworkService : public std::enable_shared_from_this<NetworkService> {
|
||||
public:
|
||||
NetworkService(asio::io_context &, asio::ip::tcp::endpoint, int);
|
||||
|
||||
void start();
|
||||
|
||||
private:
|
||||
asio::io_context &ctx_;
|
||||
asio::ip::tcp::endpoint endpoint_;
|
||||
std::vector<std::jthread> threads_;
|
||||
asio::executor_work_guard<asio::io_context::executor_type> work_guard_;
|
||||
|
||||
asio::awaitable<void> listen();
|
||||
|
||||
asio::awaitable<void> session(asio::ip::tcp::socket);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue