MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / add

Method add

include/behaviortree_cpp/utils/timer_queue.h:100–115  ·  view source on GitHub ↗

Adds a new timer \return Returns the ID of the new timer. You can use this ID to cancel the timer

Source from the content-addressed store, hash-verified

98 // Returns the ID of the new timer. You can use this ID to cancel the
99 // timer
100 uint64_t add(std::chrono::milliseconds milliseconds, std::function<void(bool)> handler)
101 {
102 WorkItem item;
103 item.end = ClockT::now() + milliseconds;
104 item.handler = std::move(handler);
105
106 std::unique_lock<std::mutex> lk(m_mtx);
107 uint64_t id = ++m_idcounter;
108 item.id = id;
109 m_items.push(std::move(item));
110 lk.unlock();
111
112 // Something changed, so wake up timer thread
113 m_checkWork.notify();
114 return id;
115 }
116
117 //! Cancels the specified timer
118 // \return

Callers

nothing calls this directly

Calls 4

moveFunction · 0.85
pushMethod · 0.80
unlockMethod · 0.80
notifyMethod · 0.45

Tested by

no test coverage detected