proxygen
ExecutorLoopController-inl.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 namespace folly {
20 namespace fibers {
21 
23  : executor_(executor) {}
24 
26 
28  fm_ = fm;
29 }
30 
32  // add() is thread-safe, so this isn't properly optimized for addTask()
33  if (!executorKeepAlive_) {
35  }
36  executor_->add([this]() { return runLoop(); });
37 }
38 
40  if (!executorKeepAlive_) {
41  if (!fm_->hasTasks()) {
42  return;
43  }
45  }
47  if (!fm_->hasTasks()) {
49  }
50 }
51 
53  executor_->add(
54  [this, executorKeepAlive = getKeepAliveToken(executor_)]() mutable {
55  if (fm_->shouldRunLoopRemote()) {
56  return runLoop();
57  }
58  });
59 }
60 
62  std::function<void()>,
63  TimePoint) {
64  throw std::logic_error("Time schedule isn't supported by asyncio executor");
65 }
66 
67 } // namespace fibers
68 } // namespace folly
virtual void add(Func)=0
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
void timedSchedule(std::function< void()> func, TimePoint time) override
std::chrono::time_point< Clock > TimePoint
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
Single-threaded task execution engine.
Executor::KeepAlive< ExecutorT > getKeepAliveToken(ExecutorT *executor)
Definition: Executor.h:200
void setFiberManager(fibers::FiberManager *fm) override