| 315 | typename T |
| 316 | > |
| 317 | void timer_heavy<T>:: |
| 318 | thread ( |
| 319 | ) |
| 320 | { |
| 321 | auto_mutex M(m); |
| 322 | unsigned long delay_remaining; |
| 323 | uint64 current_time = ts.get_timestamp(); |
| 324 | |
| 325 | if (current_time < next_time_to_run) |
| 326 | delay_remaining = static_cast<unsigned long>((next_time_to_run-current_time)/1000); |
| 327 | else |
| 328 | delay_remaining = 0; |
| 329 | |
| 330 | while (stop_running == false) |
| 331 | { |
| 332 | if (delay_remaining > 0) |
| 333 | s.wait_or_timeout(delay_remaining); |
| 334 | |
| 335 | if (stop_running) |
| 336 | break; |
| 337 | |
| 338 | current_time = ts.get_timestamp(); |
| 339 | if (current_time < next_time_to_run) |
| 340 | { |
| 341 | // then we woke up too early so we should keep waiting |
| 342 | delay_remaining = static_cast<unsigned long>((next_time_to_run-current_time)/1000); |
| 343 | |
| 344 | // rounding might make this be zero anyway. So if it is |
| 345 | // then we will say we have hit the next time to run. |
| 346 | if (delay_remaining > 0) |
| 347 | continue; |
| 348 | } |
| 349 | |
| 350 | // call the action function |
| 351 | m.unlock(); |
| 352 | (ao.*af)(); |
| 353 | m.lock(); |
| 354 | |
| 355 | current_time = ts.get_timestamp(); |
| 356 | next_time_to_run = current_time + delay*1000; |
| 357 | delay_remaining = delay; |
| 358 | } |
| 359 | running = false; |
| 360 | stop_running = false; |
| 361 | s.broadcast(); |
| 362 | } |
| 363 | |
| 364 | // ---------------------------------------------------------------------------------------- |
| 365 |
nothing calls this directly
no test coverage detected