1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #ifndef __SOCKETENGINE_POLL__
15 #define __SOCKETENGINE_POLL__
20 #include "inspircd_config.h"
22 #include "socketengine.h"
26 #define __USE_XOPEN /* fuck every fucking OS ever made. needed by poll.h to work.*/
32 #define struct pollfd WSAPOLLFD
38 /** A specialisation of the SocketEngine class, designed to use poll().
40 class PollEngine : public SocketEngine
43 /** These are used by poll() to hold socket events
45 struct pollfd *events;
46 /** This map maps fds to an index in the events array.
48 std::map<int, unsigned int> fd_mappings;
50 /** Create a new PollEngine
53 /** Delete a PollEngine
55 virtual ~PollEngine();
56 virtual bool AddFd(EventHandler* eh, int event_mask);
57 virtual void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
58 virtual EventHandler* GetRef(int fd);
59 virtual bool DelFd(EventHandler* eh, bool force = false);
60 virtual int DispatchEvents();
61 virtual std::string GetName();
64 /** Creates a SocketEngine
66 class SocketEngineFactory
69 /** Create a new instance of SocketEngine based on PollEngine
71 SocketEngine* Create() { return new PollEngine; }