mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
/* +------------------------------------+
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
* +------------------------------------+
|
|
*
|
|
* InspIRCd: (C) 2002-2010 InspIRCd Development Team
|
|
* See: http://wiki.inspircd.org/Credits
|
|
*
|
|
* This program is free but copyrighted software; see
|
|
* the file COPYING for details.
|
|
*
|
|
* ---------------------------------------------------
|
|
*/
|
|
|
|
#ifndef __THREADENGINE__
|
|
#define __THREADENGINE__
|
|
|
|
#ifdef WINDOWS
|
|
// #include "threadengines/threadengine_win32.h"
|
|
#else
|
|
#include "threadengines/threadengine_pthread.h"
|
|
#endif
|
|
|
|
class CoreExport Job : public classbase
|
|
{
|
|
public:
|
|
ModuleRef owner;
|
|
private:
|
|
bool cancelled;
|
|
public:
|
|
Job(Module* Creator) : owner(Creator), cancelled(false) {}
|
|
virtual ~Job() {}
|
|
/** Run in thread context.
|
|
*/
|
|
virtual void run() = 0;
|
|
/** Run in the main thread context at some point after run() returns */
|
|
virtual void finish() = 0;
|
|
/** Override this to cause a thread wakeup, or simply poll for cancellation in run() */
|
|
virtual void cancel() { cancelled = true; }
|
|
/** Return true to ensure that this job finishes prior to the unload of the given module */
|
|
virtual bool BlocksUnload(Module* m);
|
|
inline bool IsCancelled() { return cancelled; }
|
|
};
|
|
|
|
// Mutexes are available. Be careful not to block the main thread.
|
|
// Condition variables (cross-thread signalling) are not yet available, because
|
|
// no use case for them has been presented
|
|
|
|
#endif
|
|
|