decouple masterserver from network host game settings into two seperate threads

This commit is contained in:
Mark Vejvoda
2013-11-07 18:39:08 +00:00
parent b7a7d3bc4a
commit 9b097fd911
19 changed files with 300 additions and 89 deletions

View File

@@ -71,10 +71,10 @@ typedef void taskFunctionCallback(BaseThread *callingThread);
//
class SimpleTaskCallbackInterface {
public:
virtual void simpleTask(BaseThread *callingThread) = 0;
virtual void simpleTask(BaseThread *callingThread,void *userdata) = 0;
virtual void setupTask(BaseThread *callingThread) { }
virtual void shutdownTask(BaseThread *callingThread) { }
virtual void setupTask(BaseThread *callingThread,void *userdata) { }
virtual void shutdownTask(BaseThread *callingThread,void *userdata) { }
virtual ~SimpleTaskCallbackInterface() {}
};
@@ -97,14 +97,26 @@ protected:
time_t lastExecuteTimestamp;
taskFunctionCallback *overrideShutdownTask;
void *userdata;
bool wantSetupAndShutdown;
public:
SimpleTaskThread(SimpleTaskCallbackInterface *simpleTaskInterface,
unsigned int executionCount=0,
unsigned int millisecsBetweenExecutions=0,
bool needTaskSignal = false);
bool needTaskSignal = false,
void *userdata=NULL,
bool wantSetupAndShutdown=true);
virtual ~SimpleTaskThread();
virtual void * getUserdata() { return userdata; }
virtual int getUserdataAsInt() {
int value = 0;
if(userdata) {
value = *((int*)&userdata);
}
return value;
}
virtual void execute();
virtual bool canShutdown(bool deleteSelfIfShutdownDelayed=false);