]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengines/socketengine_kqueue.h
Update all wiki links to point to the new wiki. This was done automatically with...
[user/henk/code/inspircd.git] / include / socketengines / socketengine_kqueue.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 __SOCKETENGINE_KQUEUE__
15 #define __SOCKETENGINE_KQUEUE__
16
17 #include <vector>
18 #include <string>
19 #include <map>
20 #include "inspircd_config.h"
21 #include "inspircd.h"
22 #include <sys/types.h>
23 #include <sys/event.h>
24 #include <sys/time.h>
25 #include "socketengine.h"
26
27 class InspIRCd;
28
29 /** A specialisation of the SocketEngine class, designed to use FreeBSD kqueue().
30  */
31 class KQueueEngine : public SocketEngine
32 {
33 private:
34         /** These are used by kqueue() to hold socket events
35          */
36         struct kevent* ke_list;
37         /** This is a specialised time value used by kqueue()
38          */
39         struct timespec ts;
40 public:
41         /** Create a new KQueueEngine
42          * @param Instance The creator of this object
43          */
44         KQueueEngine(InspIRCd* Instance);
45         /** Delete a KQueueEngine
46          */
47         virtual ~KQueueEngine();
48         virtual bool AddFd(EventHandler* eh);
49         virtual int GetMaxFds();
50         virtual int GetRemainingFds();
51         virtual bool DelFd(EventHandler* eh, bool force = false);
52         virtual int DispatchEvents();
53         virtual std::string GetName();
54         virtual void WantWrite(EventHandler* eh);
55         virtual void RecoverFromFork();
56 };
57
58 /** Creates a SocketEngine
59  */
60 class SocketEngineFactory
61 {
62  public:
63         /** Create a new instance of SocketEngine based on KQueueEngine
64          */
65         SocketEngine* Create(InspIRCd* Instance) { return new KQueueEngine(Instance); }
66 };
67
68 #endif