* Add a trigger to be scheduled "seconds" seconds after the * last currently scheduled trigger. * * (Note that this is not "seconds" from now. That might be more logical, but * would require slightly more complicated sorting, rather than just appending * to the end.) */
| 419 | * to the end.) |
| 420 | */ |
| 421 | void add_trigger(unsigned int seconds, |
| 422 | const std::shared_ptr<TTransport>& transport, |
| 423 | uint32_t write_len) { |
| 424 | auto* info = new TriggerInfo(seconds, transport, write_len); |
| 425 | { |
| 426 | apache::thrift::concurrency::Synchronized s(g_alarm_monitor); |
| 427 | if (g_triggerInfo == nullptr) { |
| 428 | // This is the first trigger. |
| 429 | // Set g_triggerInfo, and schedule the alarm |
| 430 | g_triggerInfo = info; |
| 431 | g_alarm_monitor.notify(); |
| 432 | } else { |
| 433 | // Add this trigger to the end of the list |
| 434 | TriggerInfo* prev = g_triggerInfo; |
| 435 | while (prev->next) { |
| 436 | prev = prev->next; |
| 437 | } |
| 438 | prev->next = info; |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | void clear_triggers() { |
| 444 | TriggerInfo* info = nullptr; |
no test coverage detected