MCPcopy Create free account
hub / github.com/davisking/dlib / thread

Method thread

dlib/timer/timer.cpp:165–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163// ----------------------------------------------------------------------------------------
164
165 void timer_global_clock::
166 thread()
167 {
168 auto_mutex M(m);
169 while (!shutdown)
170 {
171 unsigned long delay = 100000;
172
173 tm.reset();
174 tm.move_next();
175 // loop and start all the action functions for timers that should have
176 // triggered.
177 while(tm.current_element_valid())
178 {
179 const uint64 cur_time = ts.get_timestamp();
180 uint64 t = tm.element().key();
181 // if the next event in tm is ready to trigger
182 if (t <= cur_time + 999)
183 {
184 // remove this event from the tm map
185 timer_base* r = tm.element().value();
186 timer_base* rtemp;
187 tm.remove_current_element(t,rtemp);
188 r->in_global_clock = false;
189
190 // if this timer is still "running" then start its action function
191 if (r->running)
192 {
193 r->restart();
194 }
195 }
196 else
197 {
198 // there aren't any more timers that should trigger so we compute
199 // the delay to the next timer event.
200 delay = static_cast<unsigned long>((t - cur_time)/1000);
201 break;
202 }
203 }
204
205 s.wait_or_timeout(delay);
206 }
207 }
208
209// ----------------------------------------------------------------------------------------
210

Callers

nothing calls this directly

Calls 6

get_timestampMethod · 0.80
valueMethod · 0.80
resetMethod · 0.45
move_nextMethod · 0.45
current_element_validMethod · 0.45
wait_or_timeoutMethod · 0.45

Tested by

no test coverage detected