Rename the callback

This commit is contained in:
Learath2 2017-10-19 18:13:28 +02:00
parent 30aebc9cf4
commit b8b4f7771d
4 changed files with 9 additions and 9 deletions

View file

@ -26,7 +26,7 @@ public:
virtual void Init() = 0; virtual void Init() = 0;
virtual void InitLogfile() = 0; virtual void InitLogfile() = 0;
virtual void HostLookup(CHostLookup *pLookup, const char *pHostname, int Nettype) = 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); extern IEngine *CreateEngine(const char *pAppname, bool Silent);

View file

@ -106,11 +106,11 @@ public:
AddJob(&pLookup->m_Job, HostLookupThread, pLookup); 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) if(g_Config.m_Debug)
dbg_msg("engine", "job added"); dbg_msg("engine", "job added");
m_JobPool.Add(pJob, pfnFunc, pData, pfnCB); m_JobPool.Add(pJob, pfnFunc, pData, pfnDestroy);
} }
}; };

View file

@ -53,8 +53,8 @@ void CJobPool::WorkerThread(void *pUser)
pJob->m_Status = CJob::STATE_RUNNING; pJob->m_Status = CJob::STATE_RUNNING;
pJob->m_Result = pJob->m_pfnFunc(pJob->m_pFuncData); pJob->m_Result = pJob->m_pfnFunc(pJob->m_pFuncData);
pJob->m_Status = CJob::STATE_DONE; pJob->m_Status = CJob::STATE_DONE;
if(pJob->m_pfnCallback) if(pJob->m_pfnDestroy)
pJob->m_pfnCallback(pJob, pJob->m_pFuncData); pJob->m_pfnDestroy(pJob, pJob->m_pFuncData);
} }
} }
@ -69,12 +69,12 @@ int CJobPool::Init(int NumThreads)
return 0; 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)); mem_zero(pJob, sizeof(CJob));
pJob->m_pfnFunc = pfnFunc; pJob->m_pfnFunc = pfnFunc;
pJob->m_pFuncData = pData; pJob->m_pFuncData = pData;
pJob->m_pfnCallback = pfnCallback; pJob->m_pfnDestroy = pfnDestroy;
lock_wait(m_Lock); lock_wait(m_Lock);

View file

@ -19,7 +19,7 @@ class CJob
volatile int m_Result; volatile int m_Result;
JOBFUNC m_pfnFunc; JOBFUNC m_pfnFunc;
CBFUNC m_pfnCallback; CBFUNC m_pfnDestroy;
void *m_pFuncData; void *m_pFuncData;
public: public:
CJob() CJob()
@ -61,6 +61,6 @@ public:
~CJobPool(); ~CJobPool();
int Init(int NumThreads); 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 #endif