1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #ifndef __THREADENGINE__
15 #define __THREADENGINE__
20 #include "inspircd_config.h"
23 /** Derive from this class to implement your own threaded sections of
24 * code. Be sure to keep your code thread-safe and not prone to deadlocks
25 * and race conditions if you MUST use threading!
27 class CoreExport Thread : public Extensible
30 /** Set to true when the thread is to exit
34 /** Opaque thread state managed by threading engine
38 /** Set Creator to NULL at this point
40 Thread() : ExitFlag(false), state(NULL)
44 /** If this thread has a Creator set, call it to
51 state->FreeThread(this);
56 /** Override this method to put your actual
59 virtual void Run() = 0;
61 /** Signal the thread to exit gracefully.
63 void SetExitFlag(bool value)
68 /** Get thread's current exit status.
69 * (are we being asked to exit?)