| 274 | } |
| 275 | |
| 276 | void TimerManager::remove(shared_ptr<Runnable> task) { |
| 277 | Synchronized s(monitor_); |
| 278 | if (state_ != TimerManager::STARTED) { |
| 279 | throw IllegalStateException(); |
| 280 | } |
| 281 | bool found = false; |
| 282 | for (auto ix = taskMap_.begin(); ix != taskMap_.end();) { |
| 283 | if (*ix->second == task) { |
| 284 | found = true; |
| 285 | taskCount_--; |
| 286 | taskMap_.erase(ix++); |
| 287 | } else { |
| 288 | ++ix; |
| 289 | } |
| 290 | } |
| 291 | if (!found) { |
| 292 | throw NoSuchTaskException(); |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | void TimerManager::remove(Timer handle) { |
| 297 | Synchronized s(monitor_); |