Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "precompiled.hpp"
#include "timers.hpp"
#include "blob.hpp"
#include "err.hpp"

#include <algorithm>
Expand Down Expand Up @@ -30,7 +31,7 @@ int zmq::timers_t::add (size_t interval_, timers_timer_fn handler_, void *arg_)

uint64_t when = _clock.now_ms () + interval_;
timer_t timer = {++_next_timer_id, interval_, handler_, arg_};
_timers.insert (timersmap_t::value_type (when, timer));
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (when, timer);

return timer.timer_id;
}
Expand Down Expand Up @@ -79,7 +80,7 @@ int zmq::timers_t::set_interval (int timer_id_, size_t interval_)
timer.interval = interval_;
uint64_t when = _clock.now_ms () + interval_;
_timers.erase (it);
_timers.insert (timersmap_t::value_type (when, timer));
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (when, timer);

return 0;
}
Expand All @@ -97,7 +98,7 @@ int zmq::timers_t::reset (int timer_id_)
timer_t timer = it->second;
uint64_t when = _clock.now_ms () + timer.interval;
_timers.erase (it);
_timers.insert (timersmap_t::value_type (when, timer));
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (when, timer);

return 0;
}
Expand Down Expand Up @@ -147,8 +148,7 @@ int zmq::timers_t::execute ()

timer.handler (timer.timer_id, timer.arg);

_timers.insert (
timersmap_t::value_type (now + timer.interval, timer));
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (now + timer.interval, timer);
}
}
_timers.erase (begin, it);
Expand Down
Loading