]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/threadengine.h
Each Thread class must have its own thread handle, duh. Someone take away my craqpipe...
[user/henk/code/inspircd.git] / include / threadengine.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __THREADENGINE__
15 #define __THREADENGINE__
16
17 #include <vector>
18 #include <string>
19 #include <map>
20 #include "inspircd_config.h"
21 #include "base.h"
22
23 class InspIRCd;
24 class Thread;
25
26
27 class CoreExport ThreadEngine : public Extensible
28 {
29  protected:
30
31          InspIRCd* ServerInstance;
32          Thread* NewThread;
33
34  public:
35
36         ThreadEngine(InspIRCd* Instance);
37
38         virtual ~ThreadEngine();
39
40         virtual bool Mutex(bool enable) = 0;
41
42         virtual void Run() = 0;
43
44         virtual void Create(Thread* thread_to_init) = 0;
45
46         virtual void FreeThread(Thread* thread) = 0;
47 };
48
49 class CoreExport Thread : public Extensible
50 {
51  public:
52
53         ThreadEngine* Creator;
54
55         Thread() : Creator(NULL)
56         {
57         }
58
59         virtual ~Thread()
60         {
61                 if (Creator)
62                         Creator->FreeThread(this);
63         }
64
65         virtual void Run() = 0;
66 };
67
68
69
70 #endif
71