mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-10-11 19:14:30 +00:00
use jthread to join thread on scope exit
This commit is contained in:
+1
-4
@@ -718,7 +718,7 @@ void TNetwork::TCPClient(const std::weak_ptr<TClient>& c) {
|
|||||||
OnConnect(c);
|
OnConnect(c);
|
||||||
RegisterThread("(" + std::to_string(c.lock()->GetID()) + ") \"" + c.lock()->GetName() + "\"");
|
RegisterThread("(" + std::to_string(c.lock()->GetID()) + ") \"" + c.lock()->GetName() + "\"");
|
||||||
|
|
||||||
std::thread QueueSync(&TNetwork::Looper, this, c);
|
std::jthread QueueSync(&TNetwork::Looper, this, c);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (c.expired())
|
if (c.expired())
|
||||||
@@ -744,9 +744,6 @@ void TNetwork::TCPClient(const std::weak_ptr<TClient>& c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QueueSync.joinable())
|
|
||||||
QueueSync.join();
|
|
||||||
|
|
||||||
if (!c.expired()) {
|
if (!c.expired()) {
|
||||||
auto Client = c.lock();
|
auto Client = c.lock();
|
||||||
OnDisconnect(c);
|
OnDisconnect(c);
|
||||||
|
|||||||
Reference in New Issue
Block a user