mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Rename the callback
This commit is contained in:
parent
30aebc9cf4
commit
b8b4f7771d
|
@ -26,7 +26,7 @@ public:
|
|||
virtual void Init() = 0;
|
||||
virtual void InitLogfile() = 0;
|
||||
virtual void HostLookup(CHostLookup *pLookup, const char *pHostname, int Nettype) = 0;
|
||||
virtual void AddJob(CJob *pJob, JOBFUNC pfnFunc, void *pData, CBFUNC pfnCB = 0) = 0;
|
||||
virtual void AddJob(CJob *pJob, JOBFUNC pfnFunc, void *pData, CBFUNC pfnDestroy = 0) = 0;
|
||||
};
|
||||
|
||||
extern IEngine *CreateEngine(const char *pAppname, bool Silent);
|
||||
|
|
|
@ -106,11 +106,11 @@ public:
|
|||
AddJob(&pLookup->m_Job, HostLookupThread, pLookup);
|
||||
}
|
||||
|
||||
void AddJob(CJob *pJob, JOBFUNC pfnFunc, void *pData, CBFUNC pfnCB = 0)
|
||||
void AddJob(CJob *pJob, JOBFUNC pfnFunc, void *pData, CBFUNC pfnDestroy = 0)
|
||||
{
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("engine", "job added");
|
||||
m_JobPool.Add(pJob, pfnFunc, pData, pfnCB);
|
||||
m_JobPool.Add(pJob, pfnFunc, pData, pfnDestroy);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ void CJobPool::WorkerThread(void *pUser)
|
|||
pJob->m_Status = CJob::STATE_RUNNING;
|
||||
pJob->m_Result = pJob->m_pfnFunc(pJob->m_pFuncData);
|
||||
pJob->m_Status = CJob::STATE_DONE;
|
||||
if(pJob->m_pfnCallback)
|
||||
pJob->m_pfnCallback(pJob, pJob->m_pFuncData);
|
||||
if(pJob->m_pfnDestroy)
|
||||
pJob->m_pfnDestroy(pJob, pJob->m_pFuncData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,12 +69,12 @@ int CJobPool::Init(int NumThreads)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CJobPool::Add(CJob *pJob, JOBFUNC pfnFunc, void *pData, CBFUNC pfnCallback)
|
||||
int CJobPool::Add(CJob *pJob, JOBFUNC pfnFunc, void *pData, CBFUNC pfnDestroy)
|
||||
{
|
||||
mem_zero(pJob, sizeof(CJob));
|
||||
pJob->m_pfnFunc = pfnFunc;
|
||||
pJob->m_pFuncData = pData;
|
||||
pJob->m_pfnCallback = pfnCallback;
|
||||
pJob->m_pfnDestroy = pfnDestroy;
|
||||
|
||||
lock_wait(m_Lock);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class CJob
|
|||
volatile int m_Result;
|
||||
|
||||
JOBFUNC m_pfnFunc;
|
||||
CBFUNC m_pfnCallback;
|
||||
CBFUNC m_pfnDestroy;
|
||||
void *m_pFuncData;
|
||||
public:
|
||||
CJob()
|
||||
|
@ -61,6 +61,6 @@ public:
|
|||
~CJobPool();
|
||||
|
||||
int Init(int NumThreads);
|
||||
int Add(CJob *pJob, JOBFUNC pfnFunc, void *pData, CBFUNC pfnCallback = 0);
|
||||
int Add(CJob *pJob, JOBFUNC pfnFunc, void *pData, CBFUNC pfnDestroy = 0);
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue