MCPcopy Create free account
hub / github.com/apache/thrift / removeExpired

Method removeExpired

lib/cpp/src/thrift/concurrency/ThreadManager.cpp:527–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527void ThreadManager::Impl::removeExpired(bool justOne) {
528 // this is always called under a lock
529 if (tasks_.empty()) {
530 return;
531 }
532 auto now = std::chrono::steady_clock::now();
533
534 for (auto it = tasks_.begin(); it != tasks_.end(); )
535 {
536 if ((*it)->getExpireTime() && *((*it)->getExpireTime()) < now) {
537 if (expireCallback_) {
538 expireCallback_((*it)->getRunnable());
539 }
540 it = tasks_.erase(it);
541 ++expiredCount_;
542 if (justOne) {
543 return;
544 }
545 }
546 else
547 {
548 ++it;
549 }
550 }
551}
552
553void ThreadManager::Impl::setExpireCallback(ExpireCallback expireCallback) {
554 Guard g(mutex_);

Callers

nothing calls this directly

Calls 5

nowFunction · 0.85
emptyMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
getRunnableMethod · 0.45

Tested by

no test coverage detected