+
+ std::shared_ptr<void> add_tick_listener(std::function<void()> listener)
+ {
+ return lock(tick_listeners_mutex_, [&]
+ {
+ auto tick_listener_id = last_tick_listener_id++;
+ tick_listeners_.insert(std::make_pair(tick_listener_id, listener));
+
+ return std::shared_ptr<void>(nullptr, [=](void*)
+ {
+ lock(tick_listeners_mutex_, [&]
+ {
+ tick_listeners_.erase(tick_listener_id);
+ });
+ });
+ });
+ }