]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengine_epoll.h
Fix this so it works, passes test case. Provide a method to query for a bit and to...
[user/henk/code/inspircd.git] / include / socketengine_epoll.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15 */
16
17 #ifndef __SOCKETENGINE_EPOLL__
18 #define __SOCKETENGINE_EPOLL__
19
20 #include <vector>
21 #include <string>
22 #include <map>
23 #include "inspircd_config.h"
24 #include "globals.h"
25 #include "inspircd.h"
26 #include "socketengine.h"
27 #include <sys/epoll.h>
28 #define EP_DELAY 5
29
30 class InspIRCd;
31
32 /** A specialisation of the SocketEngine class, designed to use linux 2.6 epoll().
33  */
34 class EPollEngine : public SocketEngine
35 {
36 private:
37         /** These are used by epoll() to hold socket events
38          */
39         struct epoll_event events[MAX_DESCRIPTORS];
40 public:
41         /** Create a new EPollEngine
42          * @param Instance The creator of this object
43          */
44         EPollEngine(InspIRCd* Instance);
45         /** Delete an EPollEngine
46          */
47         virtual ~EPollEngine();
48         virtual bool AddFd(EventHandler* eh);
49         virtual int GetMaxFds();
50         virtual int GetRemainingFds();
51         virtual bool DelFd(EventHandler* eh);
52         virtual int DispatchEvents();
53         virtual std::string GetName();
54         virtual void WantWrite(EventHandler* eh);
55 };
56
57 /** Creates a SocketEngine
58  */
59 class SocketEngineFactory
60 {
61 public:
62         /** Create a new instance of SocketEngine based on EpollEngine
63          */
64         SocketEngine* Create(InspIRCd* Instance) { return new EPollEngine(Instance); }
65 };
66
67 #endif