]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengine_kqueue.h
A ton more clear() and empty() stuff thats been lingering on the long term todo for...
[user/henk/code/inspircd.git] / include / socketengine_kqueue.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 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 __SOCKETENGINE_KQUEUE__
15 #define __SOCKETENGINE_KQUEUE__
16
17 #include <vector>
18 #include <string>
19 #include <map>
20 #include "inspircd_config.h"
21 #include "globals.h"
22 #include "inspircd.h"
23 #include <sys/types.h>
24 #include <sys/event.h>
25 #include <sys/time.h>
26 #include "socketengine.h"
27
28 class InspIRCd;
29
30 /** A specialisation of the SocketEngine class, designed to use FreeBSD kqueue().
31  */
32 class KQueueEngine : public SocketEngine
33 {
34 private:
35         /** These are used by kqueue() to hold socket events
36          */
37         struct kevent ke_list[MAX_DESCRIPTORS];
38         /** This is a specialised time value used by kqueue()
39          */
40         struct timespec ts;
41 public:
42         /** Create a new KQueueEngine
43          * @param Instance The creator of this object
44          */
45         KQueueEngine(InspIRCd* Instance);
46         /** Delete a KQueueEngine
47          */
48         virtual ~KQueueEngine();
49         virtual bool AddFd(EventHandler* eh);
50         virtual int GetMaxFds();
51         virtual int GetRemainingFds();
52         virtual bool DelFd(EventHandler* eh, bool force = false);
53         virtual int DispatchEvents();
54         virtual std::string GetName();
55         virtual void WantWrite(EventHandler* eh);
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