use jthread
This commit is contained in:
@@ -5,10 +5,12 @@
|
||||
namespace blitz {
|
||||
namespace network {
|
||||
|
||||
EnetServer::EnetServer(std::uint16_t port) : m_Running(true) {
|
||||
m_Host.Create(Nz::NetProtocol::Any, port, 80);
|
||||
m_Host.AllowsIncomingConnections(true);
|
||||
m_Thread = std::thread(&EnetServer::WorkerThread, this);
|
||||
EnetServer::EnetServer(std::uint16_t a_Port) : m_Running(true) {
|
||||
m_Running = m_Host.Create(Nz::NetProtocol::Any, a_Port, 80);
|
||||
if (m_Running) {
|
||||
m_Host.AllowsIncomingConnections(true);
|
||||
m_Thread = std::jthread(&EnetServer::WorkerThread, this);
|
||||
}
|
||||
}
|
||||
|
||||
void EnetServer::WorkerThread() {
|
||||
@@ -96,7 +98,7 @@ void EnetServer::RemoveConnection(std::uint16_t a_PeerId) {
|
||||
|
||||
void EnetServer::Destroy() {
|
||||
m_Running = false;
|
||||
m_Thread.join();
|
||||
m_Thread.request_stop();
|
||||
m_Host.Destroy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user