Commit 9e3e7456 authored by Misha Shneerson's avatar Misha Shneerson Committed by Facebook GitHub Bot

Only observe lag on tasks with Thrift's folly::RequestContext attached to it.

Reviewed By: andriigrynenko

Differential Revision: D25814958

fbshipit-source-id: abc2448bf93c5016411629936a8c7f06bb0033e6
parent add97bf4
......@@ -24,11 +24,13 @@
namespace folly {
class RequestContext;
class QueueObserver {
public:
virtual ~QueueObserver() {}
virtual intptr_t onEnqueued() = 0;
virtual intptr_t onEnqueued(const RequestContext*) = 0;
virtual void onDequeued(intptr_t) = 0;
};
......
......@@ -170,7 +170,8 @@ void CPUThreadPoolExecutor::add(
Func expireCallback) {
CPUTask task{std::move(func), expiration, std::move(expireCallback), 0};
if (auto queueObserver = getQueueObserver(0)) {
task.queueObserverPayload() = queueObserver->onEnqueued();
task.queueObserverPayload() =
queueObserver->onEnqueued(task.context_.get());
}
auto result = taskQueue_->add(std::move(task));
if (!result.reusedThread) {
......@@ -191,7 +192,8 @@ void CPUThreadPoolExecutor::add(
CPUTask task(
std::move(func), expiration, std::move(expireCallback), priority);
if (auto queueObserver = getQueueObserver(priority)) {
task.queueObserverPayload() = queueObserver->onEnqueued();
task.queueObserverPayload() =
queueObserver->onEnqueued(task.context_.get());
}
auto result = taskQueue_->addWithPriority(std::move(task), priority);
if (!result.reusedThread) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment