if (LIKELY(x->getNumPriorities() == 1)) {
x->add([this]() mutable {
SCOPE_EXIT { detachOne(); };
- RequestContext::setContext(context_);
+ RequestContextScopeGuard rctx(context_);
SCOPE_EXIT { callback_ = {}; };
callback_(std::move(*result_));
});
} else {
x->addWithPriority([this]() mutable {
SCOPE_EXIT { detachOne(); };
- RequestContext::setContext(context_);
+ RequestContextScopeGuard rctx(context_);
SCOPE_EXIT { callback_ = {}; };
callback_(std::move(*result_));
}, priority);
}
} catch (...) {
--attached_; // Account for extra ++attached_ before try
- RequestContext::setContext(context_);
+ RequestContextScopeGuard rctx(context_);
result_ = Try<T>(exception_wrapper(std::current_exception()));
SCOPE_EXIT { callback_ = {}; };
callback_(std::move(*result_));
}
} else {
SCOPE_EXIT { detachOne(); };
- RequestContext::setContext(context_);
+ RequestContextScopeGuard rctx(context_);
SCOPE_EXIT { callback_ = {}; };
callback_(std::move(*result_));
}
// this can't possibly fire if timeout->eventBase_ is nullptr
timeout->timeoutManager_->bumpHandlingTime();
- auto old_ctx =
- RequestContext::setContext(timeout->context_);
+ RequestContextScopeGuard rctx(timeout->context_);
timeout->timeoutExpired();
-
- RequestContext::setContext(old_ctx);
}
} // folly
count_--;
cb->wheel_ = nullptr;
cb->expiration_ = milliseconds(0);
- auto old_ctx =
- RequestContext::setContext(cb->context_);
+ RequestContextScopeGuard rctx(cb->context_);
cb->timeoutExpired();
- RequestContext::setContext(old_ctx);
}
}
if (count_ > 0) {
auto& data = queue_->queue_.front();
MessageT msg(std::move(data.first));
- auto old_ctx =
- RequestContext::setContext(data.second);
+ RequestContextScopeGuard rctx(std::move(data.second));
queue_->queue_.pop_front();
// Check to see if the queue is empty now.
messageAvailable(std::move(msg));
destroyedFlagPtr_ = nullptr;
- RequestContext::setContext(old_ctx);
-
// If the callback was destroyed before it returned, we are done
if (callbackDestroyed) {
return;