Commit e75e8829 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

avoid syntactic copy elision for ExecutorBlockingGuard

Summary: It cannot yet be assumed in all places.

Reviewed By: MartinSherburn

Differential Revision: D28325332

fbshipit-source-id: b48a1f9d83c2171ef3912b33c55e9cf8fe294c32
parent ba405c6b
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <atomic> #include <atomic>
#include <folly/Memory.h> #include <folly/Memory.h>
#include <folly/Optional.h>
#include <folly/concurrency/QueueObserver.h> #include <folly/concurrency/QueueObserver.h>
#include <folly/executors/task_queue/PriorityLifoSemMPMCQueue.h> #include <folly/executors/task_queue/PriorityLifoSemMPMCQueue.h>
#include <folly/executors/task_queue/PriorityUnboundedBlockingQueue.h> #include <folly/executors/task_queue/PriorityUnboundedBlockingQueue.h>
...@@ -265,15 +266,12 @@ bool CPUThreadPoolExecutor::taskShouldStop(folly::Optional<CPUTask>& task) { ...@@ -265,15 +266,12 @@ bool CPUThreadPoolExecutor::taskShouldStop(folly::Optional<CPUTask>& task) {
void CPUThreadPoolExecutor::threadRun(ThreadPtr thread) { void CPUThreadPoolExecutor::threadRun(ThreadPtr thread) {
this->threadPoolHook_.registerThread(); this->threadPoolHook_.registerThread();
auto guard = [&]() { folly::Optional<ExecutorBlockingGuard> guard; // optional until C++17
if (prohibitBlockingOnThreadPools_ == Options::Blocking::prohibit) { if (prohibitBlockingOnThreadPools_ == Options::Blocking::prohibit) {
return ExecutorBlockingGuard{ guard.emplace(ExecutorBlockingGuard::ProhibitTag{}, executorName);
ExecutorBlockingGuard::ProhibitTag{}, executorName};
} else { } else {
return ExecutorBlockingGuard{ guard.emplace(ExecutorBlockingGuard::TrackTag{}, executorName);
ExecutorBlockingGuard::TrackTag{}, executorName};
} }
}();
thread->startupBaton.post(); thread->startupBaton.post();
while (true) { while (true) {
......
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