diff options
-rw-r--r-- | src/select.cpp | 17 | ||||
-rw-r--r-- | src/select.hpp | 3 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/select.cpp b/src/select.cpp index 9d0970a..78d3afd 100644 --- a/src/select.cpp +++ b/src/select.cpp @@ -191,15 +191,8 @@ void zmq::select_t::loop () // Destroy retired event sources. if (retired) { - fd_set_t::iterator it = fds.begin(); - while (it != fds.end()) { - if (it->fd == retired_fd) { - it = fds.erase(it); - } - else { - it++; - } - } + fds.erase (std::remove_if (fds.begin (), fds.end (), + zmq::select_t::is_retired_fd), fds.end ()); retired = false; } } @@ -209,3 +202,9 @@ void zmq::select_t::worker_routine (void *arg_) { ((select_t*) arg_)->loop (); } + +bool zmq::select_t::is_retired_fd (const fd_entry_t &entry) +{ + return (entry.fd == retired_fd); +} + diff --git a/src/select.hpp b/src/select.hpp index d4fff81..916b87b 100644 --- a/src/select.hpp +++ b/src/select.hpp @@ -77,6 +77,9 @@ namespace zmq struct i_poll_events *events; }; + // Checks if an fd_entry_t is retired. + static bool is_retired_fd (const fd_entry_t &entry); + // Set of file descriptors that are used to retreive // information for fd_set. typedef std::vector <fd_entry_t> fd_set_t; |