libsimpleio: (reinhard) expose read and write marks to derived classes.
authorReinhard Pfau <reinhard.pfau@intra2net.com>
Mon, 18 Aug 2008 15:42:09 +0000 (15:42 +0000)
committerReinhard Pfau <reinhard.pfau@intra2net.com>
Mon, 18 Aug 2008 15:42:09 +0000 (15:42 +0000)
simpleio/simpleio.cpp
simpleio/simpleio.hpp

index 20c8c1c..53ed78f 100644 (file)
@@ -1387,6 +1387,10 @@ bool Backend::doOneStep(int timeout)
     ++m_count_active_steps;
 
     try {
+
+        FdSetType local_read_fds;
+        FdSetType local_write_fds;
+
         // step 1 ; collect
 
         { // step 1.1: collect fds for read/write operations
@@ -1395,10 +1399,18 @@ bool Backend::doOneStep(int timeout)
                 ++itIOList)
             {
                 if (! *itIOList) continue; // skip NULL entries
-                bool want_read  = (*itIOList)->wantRead();
-                bool want_write = (*itIOList)->wantWrite();
                 int  read_fd  = (*itIOList)->m_read_fd;
                 int  write_fd = (*itIOList)->m_write_fd;
+                bool want_read  = (read_fd >= 0) and (*itIOList)->wantRead();
+                bool want_write = (write_fd >= 0) and (*itIOList)->wantWrite();
+                if (read_fd >= 0 )
+                {
+                    local_read_fds.insert( read_fd );
+                }
+                if (write_fd >= 0)
+                {
+                    local_write_fds.insert( write_fd );
+                }
                 if (!want_read && !want_write) continue;
                 if (want_read)
                 {
@@ -1515,7 +1527,7 @@ bool Backend::doOneStep(int timeout)
                         io->m_marked_for_writing= true;
                     }
                 }
-                if (0!= (itPollItem->revents & POLLERR))
+                if ( 0!= (itPollItem->revents & POLLERR))
                 {
                     IOImplementation *io= poll_data.m_write_fd_io_map[ itPollItem->fd ];
                     if (0!= (itPollItem->events & POLLOUT))
index c9581c9..d3727be 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <string>
 #include <list>
+#include <set>
 
 #include <pointer_func.hpp>
 
@@ -281,6 +282,9 @@ class IOImplementation
             return m_write_fd;
         }
 
+        inline bool isMarkedForReading() const { return m_marked_for_reading; }
+        inline bool isMarkedForWriting() const { return m_marked_for_writing; }
+
 
     protected:
         virtual void doRead();
@@ -411,6 +415,9 @@ class SimpleIO2 : public IOImplementation2
 class Backend
 {
     public:
+        typedef std::set< int > FdSetType;
+
+    public:
 
         bool doOneStep(int ms_timeout= -1);
         void run();