Simplified uses of erase

This commit is contained in:
Simon Giesecke
2018-08-07 10:30:55 +02:00
parent 6357890ff6
commit fa976f87f9
7 changed files with 39 additions and 49 deletions

View File

@@ -32,6 +32,8 @@
#include "clock.hpp"
#include "err.hpp"
#include <algorithm>
zmq::mailbox_safe_t::mailbox_safe_t (mutex_t *sync_) : _sync (sync_)
{
// Get the pipe into passive state. That way, if the users starts by
@@ -58,13 +60,9 @@ void zmq::mailbox_safe_t::add_signaler (signaler_t *signaler_)
void zmq::mailbox_safe_t::remove_signaler (signaler_t *signaler_)
{
std::vector<signaler_t *>::iterator it = _signalers.begin ();
// TODO: make a copy of array and signal outside the lock
for (; it != _signalers.end (); ++it) {
if (*it == signaler_)
break;
}
std::vector<signaler_t *>::iterator it =
std::find (_signalers.begin (), _signalers.end (), signaler_);
if (it != _signalers.end ())
_signalers.erase (it);