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 @@ ...@@ -24,11 +24,13 @@
namespace folly { namespace folly {
class RequestContext;
class QueueObserver { class QueueObserver {
public: public:
virtual ~QueueObserver() {} virtual ~QueueObserver() {}
virtual intptr_t onEnqueued() = 0; virtual intptr_t onEnqueued(const RequestContext*) = 0;
virtual void onDequeued(intptr_t) = 0; virtual void onDequeued(intptr_t) = 0;
}; };
......
...@@ -170,7 +170,8 @@ void CPUThreadPoolExecutor::add( ...@@ -170,7 +170,8 @@ void CPUThreadPoolExecutor::add(
Func expireCallback) { Func expireCallback) {
CPUTask task{std::move(func), expiration, std::move(expireCallback), 0}; CPUTask task{std::move(func), expiration, std::move(expireCallback), 0};
if (auto queueObserver = getQueueObserver(0)) { if (auto queueObserver = getQueueObserver(0)) {
task.queueObserverPayload() = queueObserver->onEnqueued(); task.queueObserverPayload() =
queueObserver->onEnqueued(task.context_.get());
} }
auto result = taskQueue_->add(std::move(task)); auto result = taskQueue_->add(std::move(task));
if (!result.reusedThread) { if (!result.reusedThread) {
...@@ -191,7 +192,8 @@ void CPUThreadPoolExecutor::add( ...@@ -191,7 +192,8 @@ void CPUThreadPoolExecutor::add(
CPUTask task( CPUTask task(
std::move(func), expiration, std::move(expireCallback), priority); std::move(func), expiration, std::move(expireCallback), priority);
if (auto queueObserver = getQueueObserver(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); auto result = taskQueue_->addWithPriority(std::move(task), priority);
if (!result.reusedThread) { 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