]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengine_ports.h
A ton more clear() and empty() stuff thats been lingering on the long term todo for...
[user/henk/code/inspircd.git] / include / socketengine_ports.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_PORTS__
15 #define __SOCKETENGINE_PORTS__
16
17 #ifndef __sun
18 # error You need Solaris 10 or later to make use of this code.
19 #endif
20
21 #include <vector>
22 #include <string>
23 #include <map>
24 #include "inspircd_config.h"
25 #include "globals.h"
26 #include "inspircd.h"
27 #include "socketengine.h"
28 #include <port.h>
29 #define EP_DELAY 5
30
31 class InspIRCd;
32
33 /** A specialisation of the SocketEngine class, designed to use linux 2.6 epoll().
34  */
35 class PortsEngine : public SocketEngine
36 {
37 private:
38         /** These are used by epoll() to hold socket events
39          */
40         port_event_t events[MAX_DESCRIPTORS];
41 public:
42         /** Create a new EPollEngine
43          * @param Instance The creator of this object
44          */
45         PortsEngine(InspIRCd* Instance);
46         /** Delete an EPollEngine
47          */
48         virtual ~PortsEngine();
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 };
57
58 /** Creates a SocketEngine
59  */
60 class SocketEngineFactory
61 {
62 public:
63         /** Create a new instance of SocketEngine based on PortsEngine
64          */
65         SocketEngine* Create(InspIRCd* Instance) { return new PortsEngine(Instance); }
66 };
67
68 #endif