| 507 | } |
| 508 | |
| 509 | std::shared_ptr<Runnable> ThreadManager::Impl::removeNextPending() { |
| 510 | Guard g(mutex_); |
| 511 | if (state_ != ThreadManager::STARTED) { |
| 512 | throw IllegalStateException( |
| 513 | "ThreadManager::Impl::removeNextPending " |
| 514 | "ThreadManager not started"); |
| 515 | } |
| 516 | |
| 517 | if (tasks_.empty()) { |
| 518 | return std::shared_ptr<Runnable>(); |
| 519 | } |
| 520 | |
| 521 | shared_ptr<ThreadManager::Task> task = tasks_.front(); |
| 522 | tasks_.pop_front(); |
| 523 | |
| 524 | return task->getRunnable(); |
| 525 | } |
| 526 | |
| 527 | void ThreadManager::Impl::removeExpired(bool justOne) { |
| 528 | // this is always called under a lock |