| 84 | #define TIMER_EMPTY -1 |
| 85 | |
| 86 | acl_int64 aio_timer_callback::del_task(unsigned int id) |
| 87 | { |
| 88 | bool ok = false; |
| 89 | std::list<aio_timer_task*>::iterator it = tasks_.begin(); |
| 90 | for (; it != tasks_.end(); ++it) { |
| 91 | if ((*it)->id == id) { |
| 92 | delete (*it); |
| 93 | tasks_.erase(it); |
| 94 | length_--; |
| 95 | ok = true; |
| 96 | break; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | if (!ok) { |
| 101 | logger_warn("timer id: %u not found", id); |
| 102 | } |
| 103 | |
| 104 | if (tasks_.empty()) { |
| 105 | return TIMER_EMPTY; |
| 106 | } |
| 107 | |
| 108 | set_time(); |
| 109 | |
| 110 | acl_int64 delay = tasks_.front()->when - present_; |
| 111 | return delay < 0 ? 0 : delay; |
| 112 | } |
| 113 | |
| 114 | acl_int64 aio_timer_callback::set_task(unsigned int id, acl_int64 delay) |
| 115 | { |