summaryrefslogtreecommitdiff
path: root/include/socketengines
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-26 01:43:09 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-26 01:43:09 +0000
commit939cb0ba987f927f1ad900d45f98ba6d8e03e9d4 (patch)
treef35510ff56e01ece2a0417c9a6fbad17fb7acfee /include/socketengines
parentc8026bc2d73344e1df526f0a80694046efa4b22a (diff)
Clean up SocketEngine interface to allow edge-triggered I/O and sockets that do not force readability.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11760 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include/socketengines')
-rw-r--r--include/socketengines/socketengine_epoll.h7
-rw-r--r--include/socketengines/socketengine_iocp.h7
-rw-r--r--include/socketengines/socketengine_kqueue.h5
-rw-r--r--include/socketengines/socketengine_poll.h6
-rw-r--r--include/socketengines/socketengine_ports.h5
-rw-r--r--include/socketengines/socketengine_select.h18
6 files changed, 13 insertions, 35 deletions
diff --git a/include/socketengines/socketengine_epoll.h b/include/socketengines/socketengine_epoll.h
index 3e08179ae..08a9b1bcc 100644
--- a/include/socketengines/socketengine_epoll.h
+++ b/include/socketengines/socketengine_epoll.h
@@ -31,6 +31,7 @@ private:
/** These are used by epoll() to hold socket events
*/
struct epoll_event* events;
+ int EngineHandle;
public:
/** Create a new EPollEngine
*/
@@ -38,13 +39,11 @@ public:
/** Delete an EPollEngine
*/
virtual ~EPollEngine();
- virtual bool AddFd(EventHandler* eh, bool writeFirst = false);
- virtual int GetMaxFds();
- virtual int GetRemainingFds();
+ virtual bool AddFd(EventHandler* eh, int event_mask);
+ virtual void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
virtual bool DelFd(EventHandler* eh, bool force = false);
virtual int DispatchEvents();
virtual std::string GetName();
- virtual void WantWrite(EventHandler* eh);
};
/** Creates a SocketEngine
diff --git a/include/socketengines/socketengine_iocp.h b/include/socketengines/socketengine_iocp.h
index dd34227d3..0f4f6bdf5 100644
--- a/include/socketengines/socketengine_iocp.h
+++ b/include/socketengines/socketengine_iocp.h
@@ -131,7 +131,7 @@ public:
* @param eh EventHandler to add
* @return True if success, false if no room
*/
- bool AddFd(EventHandler* eh, bool writeFirst = false);
+ bool AddFd(EventHandler* eh, int event_mask);
/** Gets the maximum number of file descriptors that this engine can handle.
* @return The number of file descriptors
@@ -166,10 +166,7 @@ public:
*/
std::string GetName();
- /** Queues a Write event on the specified event handler.
- * @param eh EventHandler that needs data sent on
- */
- void WantWrite(EventHandler* eh);
+ void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
/** Posts a completion event on the specified socket.
* @param eh EventHandler for message
diff --git a/include/socketengines/socketengine_kqueue.h b/include/socketengines/socketengine_kqueue.h
index a09e93553..80993e2d4 100644
--- a/include/socketengines/socketengine_kqueue.h
+++ b/include/socketengines/socketengine_kqueue.h
@@ -42,9 +42,8 @@ public:
/** Delete a KQueueEngine
*/
virtual ~KQueueEngine();
- virtual bool AddFd(EventHandler* eh, bool writeFirst = false);
- virtual int GetMaxFds();
- virtual int GetRemainingFds();
+ bool AddFd(EventHandler* eh, int event_mask);
+ void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
virtual bool DelFd(EventHandler* eh, bool force = false);
virtual int DispatchEvents();
virtual std::string GetName();
diff --git a/include/socketengines/socketengine_poll.h b/include/socketengines/socketengine_poll.h
index 725ad225c..a99ce915c 100644
--- a/include/socketengines/socketengine_poll.h
+++ b/include/socketengines/socketengine_poll.h
@@ -53,14 +53,12 @@ public:
/** Delete a PollEngine
*/
virtual ~PollEngine();
- virtual bool AddFd(EventHandler* eh, bool writeFirst = false);
+ virtual bool AddFd(EventHandler* eh, int event_mask);
+ virtual void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
virtual EventHandler* GetRef(int fd);
- virtual int GetMaxFds();
- virtual int GetRemainingFds();
virtual bool DelFd(EventHandler* eh, bool force = false);
virtual int DispatchEvents();
virtual std::string GetName();
- virtual void WantWrite(EventHandler* eh);
};
/** Creates a SocketEngine
diff --git a/include/socketengines/socketengine_ports.h b/include/socketengines/socketengine_ports.h
index 03df456f2..be8c4bad2 100644
--- a/include/socketengines/socketengine_ports.h
+++ b/include/socketengines/socketengine_ports.h
@@ -42,9 +42,8 @@ public:
/** Delete a PortsEngine
*/
virtual ~PortsEngine();
- virtual bool AddFd(EventHandler* eh, bool writeFirst = false);
- virtual int GetMaxFds();
- virtual int GetRemainingFds();
+ virtual bool AddFd(EventHandler* eh, int event_mask);
+ void OnSetEvent(EventHandler* eh, int old_event, int new_event);
virtual bool DelFd(EventHandler* eh, bool force = false);
virtual int DispatchEvents();
virtual std::string GetName();
diff --git a/include/socketengines/socketengine_select.h b/include/socketengines/socketengine_select.h
index a1993f19f..5a4aee86b 100644
--- a/include/socketengines/socketengine_select.h
+++ b/include/socketengines/socketengine_select.h
@@ -28,32 +28,18 @@
*/
class SelectEngine : public SocketEngine
{
-private:
- /** Because select() does not track an fd list for us between calls, we have one of our own
- */
- std::set<int> fds;
- /** List of writeable ones (WantWrite())
- */
- std::vector<bool> writeable;
- /** The read set and write set, populated before each call to select().
- */
- fd_set wfdset, rfdset, errfdset;
-
public:
/** Create a new SelectEngine
- * @param Instance The creator of this object
*/
SelectEngine();
/** Delete a SelectEngine
*/
virtual ~SelectEngine();
- virtual bool AddFd(EventHandler* eh, bool writeFirst = false);
- virtual int GetMaxFds();
- virtual int GetRemainingFds();
+ virtual bool AddFd(EventHandler* eh, int event_mask);
virtual bool DelFd(EventHandler* eh, bool force = false);
+ void OnSetEvent(EventHandler* eh, int, int);
virtual int DispatchEvents();
virtual std::string GetName();
- virtual void WantWrite(EventHandler* eh);
};
/** Creates a SocketEngine