]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengines/socketengine_epoll.h
Sort the module list to give a useful indicator of compile progress
[user/henk/code/inspircd.git] / include / socketengines / socketengine_epoll.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_EPOLL__
15 #define __SOCKETENGINE_EPOLL__
16
17 #include <vector>
18 #include <string>
19 #include <map>
20 #include "inspircd_config.h"
21 #include "inspircd.h"
22 #include "socketengine.h"
23 #include <sys/epoll.h>
24 #define EP_DELAY 5
25
26 /** A specialisation of the SocketEngine class, designed to use linux 2.6 epoll().
27  */
28 class EPollEngine : public SocketEngine
29 {
30 private:
31         /** These are used by epoll() to hold socket events
32          */
33         struct epoll_event* events;
34         int EngineHandle;
35 public:
36         /** Create a new EPollEngine
37          */
38         EPollEngine();
39         /** Delete an EPollEngine
40          */
41         virtual ~EPollEngine();
42         virtual bool AddFd(EventHandler* eh, int event_mask);
43         virtual void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
44         virtual bool DelFd(EventHandler* eh, bool force = false);
45         virtual int DispatchEvents();
46         virtual std::string GetName();
47 };
48
49 /** Creates a SocketEngine
50  */
51 class SocketEngineFactory
52 {
53 public:
54         /** Create a new instance of SocketEngine based on EpollEngine
55          */
56         SocketEngine* Create() { return new EPollEngine; }
57 };
58
59 #endif