19 #include <glog/logging.h> 29 DCHECK(!keepAliveCounter_);
38 std::shared_ptr<Executor>
parent) {
44 auto keepAliveCounter =
45 keepAliveCounter_.fetch_add(1, std::memory_order_relaxed);
46 DCHECK(keepAliveCounter > 0);
51 auto keepAliveCounter =
52 keepAliveCounter_.fetch_sub(1, std::memory_order_acq_rel);
53 DCHECK(keepAliveCounter > 0);
54 if (keepAliveCounter == 1) {
66 parent_->addWithPriority(
73 if (scheduled_.fetch_add(1, std::memory_order_acquire) > 0) {
83 }
catch (std::exception
const& ex) {
84 LOG(ERROR) <<
"SerialExecutor: func threw unhandled exception " 87 LOG(ERROR) <<
"SerialExecutor: func threw unhandled non-exception " 93 }
while (scheduled_.fetch_sub(1, std::memory_order_release) > 1);
void keepAliveRelease() override
fbstring exceptionStr(const std::exception &e)
constexpr detail::Map< Move > move
—— Concurrent Priority Queue Implementation ——
static KeepAlive< SerialExecutor > create(KeepAlive< Executor > parent=getKeepAliveToken(getCPUExecutor().get()))
~SerialExecutor() override
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
bool keepAliveAcquire() override
static KeepAlive< ExecutorT > getKeepAliveToken(ExecutorT *executor)
SerialExecutor(SerialExecutor const &)=delete
void addWithPriority(Func func, int8_t priority) override
Executor that guarantees serial non-concurrent execution of added tasks.
void add(Func func) override
static UniquePtr createUnique(std::shared_ptr< Executor > parent=getCPUExecutor())
std::unique_ptr< SerialExecutor, Deleter > UniquePtr
folly::Function< void()> parent