Skip to content

Commit ca8be7d

Browse files
committed
Enable emplace feature for timers
1 parent 5f408ba commit ca8be7d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/timers.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "precompiled.hpp"
44
#include "timers.hpp"
5+
#include "blob.hpp"
56
#include "err.hpp"
67

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

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

3536
return timer.timer_id;
3637
}
@@ -79,7 +80,7 @@ int zmq::timers_t::set_interval (int timer_id_, size_t interval_)
7980
timer.interval = interval_;
8081
uint64_t when = _clock.now_ms () + interval_;
8182
_timers.erase (it);
82-
_timers.insert (timersmap_t::value_type (when, timer));
83+
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (when, timer);
8384

8485
return 0;
8586
}
@@ -97,7 +98,7 @@ int zmq::timers_t::reset (int timer_id_)
9798
timer_t timer = it->second;
9899
uint64_t when = _clock.now_ms () + timer.interval;
99100
_timers.erase (it);
100-
_timers.insert (timersmap_t::value_type (when, timer));
101+
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (when, timer);
101102

102103
return 0;
103104
}
@@ -147,8 +148,7 @@ int zmq::timers_t::execute ()
147148

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

150-
_timers.insert (
151-
timersmap_t::value_type (now + timer.interval, timer));
151+
_timers.ZMQ_MAP_INSERT_OR_EMPLACE (now + timer.interval, timer);
152152
}
153153
}
154154
_timers.erase (begin, it);

0 commit comments

Comments
 (0)