mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
made server threaded, fixing issue #51
This commit is contained in:
parent
b328c1ed4d
commit
520300dc86
14 changed files with 108 additions and 37 deletions
|
|
@ -56,11 +56,21 @@ Server::~Server()
|
|||
|
||||
void Server::prepareDestroy()
|
||||
{
|
||||
clientsLock.lockForWrite();
|
||||
while (!clients.isEmpty())
|
||||
clients.first()->prepareDestroy();
|
||||
clientsLock.lockForRead();
|
||||
for (int i = 0; i < clients.size(); ++i)
|
||||
QMetaObject::invokeMethod(clients.at(i), "prepareDestroy", Qt::QueuedConnection);
|
||||
clientsLock.unlock();
|
||||
|
||||
// dirty :(
|
||||
bool done = false;
|
||||
do {
|
||||
usleep(10000);
|
||||
clientsLock.lockForRead();
|
||||
if (clients.isEmpty())
|
||||
done = true;
|
||||
clientsLock.unlock();
|
||||
} while (!done);
|
||||
|
||||
roomsLock.lockForWrite();
|
||||
QMapIterator<int, Server_Room *> roomIterator(rooms);
|
||||
while (roomIterator.hasNext())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue