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