Commit 0ad71f88 authored by Mikael Helbo Kjaer's avatar Mikael Helbo Kjaer Committed by Martin Sustrik

select now uses Erase-Remove idiom for retired fds

Signed-off-by: 's avatarMikael Helbo Kjaer <mhk@designtech.dk>
parent 085b7090
......@@ -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);
}
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment