]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/socketengines/socketengine_ports.h
Fix for bug #601
[user/henk/code/inspircd.git] / include / socketengines / socketengine_ports.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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 "inspircd.h"
26 #include "socketengine.h"
27 #include <port.h>
28
29 class InspIRCd;
30
31 /** A specialisation of the SocketEngine class, designed to use solaris 10 I/O completion ports
32  */
33 class PortsEngine : public SocketEngine
34 {
35 private:
36         /** These are used by epoll() to hold socket events
37          */
38         port_event_t* events;
39 public:
40         /** Create a new PortsEngine
41          * @param Instance The creator of this object
42          */
43         PortsEngine(InspIRCd* Instance);
44         /** Delete a PortsEngine
45          */
46         virtual ~PortsEngine();
47         virtual bool AddFd(EventHandler* eh);
48         virtual int GetMaxFds();
49         virtual int GetRemainingFds();
50         virtual bool DelFd(EventHandler* eh, bool force = false);
51         virtual int DispatchEvents();
52         virtual std::string GetName();
53         virtual void WantWrite(EventHandler* eh);
54 };
55
56 /** Creates a SocketEngine
57  */
58 class SocketEngineFactory
59 {
60 public:
61         /** Create a new instance of SocketEngine based on PortsEngine
62          */
63         SocketEngine* Create(InspIRCd* Instance) { return new PortsEngine(Instance); }
64 };
65
66 #endif
67