| 93 | work_cv_.Signal(); |
| 94 | } |
| 95 | int64_t DelayTask(int64_t delay, const Task& task) { |
| 96 | MutexLock lock(&mutex_); |
| 97 | int64_t now_time = get_micros(); |
| 98 | int64_t exe_time = now_time + delay * 1000; |
| 99 | BGItem bg_item(++last_task_id_, exe_time, task); |
| 100 | time_queue_.push(bg_item); |
| 101 | latest_[bg_item.id] = bg_item; |
| 102 | work_cv_.Signal(); |
| 103 | return bg_item.id; |
| 104 | } |
| 105 | /// Cancel a delayed task |
| 106 | /// if running, wait if non_block==false; return immediately if |
| 107 | /// non_block==true |