]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengines/socketengine_epoll.h
f66086eeea65ad1e2f8033515e4f27181e1f53c5
[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://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_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 class InspIRCd;
27
28 /** A specialisation of the SocketEngine class, designed to use linux 2.6 epoll().
29  */
30 class EPollEngine : public SocketEngine
31 {
32 private:
33         /** These are used by epoll() to hold socket events
34          */
35         struct epoll_event* events;
36 public:
37         /** Create a new EPollEngine
38          * @param Instance The creator of this object
39          */
40         EPollEngine(InspIRCd* Instance);
41         /** Delete an EPollEngine
42          */
43         virtual ~EPollEngine();
44         virtual bool AddFd(EventHandler* eh);
45         virtual int GetMaxFds();
46         virtual int GetRemainingFds();
47         virtual bool DelFd(EventHandler* eh, bool force = false);
48         virtual int DispatchEvents();
49         virtual std::string GetName();
50         virtual void WantWrite(EventHandler* eh);
51 };
52
53 /** Creates a SocketEngine
54  */
55 class SocketEngineFactory
56 {
57 public:
58         /** Create a new instance of SocketEngine based on EpollEngine
59          */
60         SocketEngine* Create(InspIRCd* Instance) { return new EPollEngine(Instance); }
61 };
62
63 #endif