]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengines/socketengine_kqueue.h
Add protocol api functions: PI->WriteChannelPrivmsg() and PI->WriteChannelNotice...
[user/henk/code/inspircd.git] / include / socketengines / socketengine_kqueue.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 __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;
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         virtual void RecoverFromFork();
57 };
58
59 /** Creates a SocketEngine
60  */
61 class SocketEngineFactory
62 {
63  public:
64         /** Create a new instance of SocketEngine based on KQueueEngine
65          */
66         SocketEngine* Create(InspIRCd* Instance) { return new KQueueEngine(Instance); }
67 };
68
69 #endif