commit x64 compilation from lulu cause the other branch dont seems to compile properly at home
This commit is contained in:
76
include/modules/io_net/io_net_server_thread.cpp
Normal file
76
include/modules/io_net/io_net_server_thread.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
GSFramework
|
||||
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#include "io_net/io_net_server_thread.h"
|
||||
#include "filesystem/io_cfile.h"
|
||||
#include "platform.h"
|
||||
#include "log/log.h"
|
||||
|
||||
using namespace GS::IO;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void NetServerThread::Execute()
|
||||
{
|
||||
{
|
||||
Threading::MutexLock lock(&server_mutex);
|
||||
server = new NetServer(basefs);
|
||||
}
|
||||
|
||||
if (server->Start(ip.c_str(), port))
|
||||
for (state.Set(1); state.Get() != 2; )
|
||||
{
|
||||
{
|
||||
Threading::MutexLock lock(&server_mutex);
|
||||
server->UpdateHost();
|
||||
}
|
||||
Platform::Get().Sleep(1);
|
||||
}
|
||||
|
||||
{
|
||||
Threading::MutexLock lock(&server_mutex);
|
||||
server = NULL;
|
||||
}
|
||||
state.Set(0);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool NetServerThread::Start(const char *_ip, int _port)
|
||||
{
|
||||
ip = _ip;
|
||||
port = _port;
|
||||
|
||||
if (!Thread::Start())
|
||||
return false;
|
||||
|
||||
while (state.Get() == 0)
|
||||
;
|
||||
|
||||
return asbool(state.Get() != -1);
|
||||
}
|
||||
void NetServerThread::Stop()
|
||||
{
|
||||
state.Set(2);
|
||||
while (state.Get() != 0); // spinlock
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void NetServerThread::GetStatistics(NetServer::Statistics &stats)
|
||||
{
|
||||
Threading::MutexLock lock(&server_mutex);
|
||||
if (server.IsValid())
|
||||
server->GetStatistics(stats);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
NetServerThread::~NetServerThread()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user