]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/threadengines/threadengine_pthread.h
ThreadEngine: remove excessive mutex use on thread creation
[user/henk/code/inspircd.git] / include / threadengines / threadengine_pthread.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __THREADENGINE_PTHREAD__
15 #define __THREADENGINE_PTHREAD__
16
17 #include <pthread.h>
18 #include "inspircd_config.h"
19 #include "base.h"
20 #include "threadengine.h"
21
22 class InspIRCd;
23
24 class CoreExport PThreadEngine : public ThreadEngine
25 {
26  public:
27
28         PThreadEngine(InspIRCd* Instance);
29
30         virtual ~PThreadEngine();
31
32         void Start(Thread* thread_to_init);
33
34         void FreeThread(Thread* thread);
35
36         const std::string GetName()
37         {
38                 return "posix-thread";
39         }
40 };
41
42 class CoreExport ThreadEngineFactory : public classbase
43 {
44  public:
45         ThreadEngine* Create(InspIRCd* ServerInstance)
46         {
47                 return new PThreadEngine(ServerInstance);
48         }
49 };
50
51 class CoreExport PThreadData : public ThreadData
52 {
53  public:
54         pthread_t pthread_id;
55         void FreeThread(Thread* toFree);
56 };
57
58 class CoreExport PosixMutex : public Mutex
59 {
60  private:
61         pthread_mutex_t putex;
62  public:
63         PosixMutex();
64         virtual void Enable(bool enable);
65         ~PosixMutex();
66 };
67
68 class CoreExport MutexFactory : public Extensible
69 {
70  protected:
71         InspIRCd* ServerInstance;
72  public:
73         MutexFactory(InspIRCd* Instance);
74         Mutex* CreateMutex();
75 };
76
77 #endif