34 FiberManager fiberManager(std::make_unique<SimpleLoopController>());
35 auto& loopController =
38 std::queue<Promise<int>> pendingRequests;
39 static const size_t maxOutstanding = 5;
41 auto loop = [&fiberManager, &loopController, &pendingRequests, &toSend]() {
42 if (pendingRequests.size() == maxOutstanding || toSend == 0) {
43 if (pendingRequests.empty()) {
46 pendingRequests.front().setValue(0);
47 pendingRequests.pop();
49 fiberManager.
addTask([&pendingRequests]() {
59 loopController.stop();
76 for (
size_t i = 0;
i < iters; ++
i) {
84 BENCHMARK(FiberManagerAllocateDeallocatePattern, iters) {
85 static const size_t kNumAllocations = 10000;
90 FiberManager fiberManager(std::make_unique<SimpleLoopController>(), opts);
92 for (
size_t iter = 0; iter < iters; ++iter) {
97 for (
size_t i = 0;
i < kNumAllocations; ++
i) {
98 fiberManager.
addTask([&fibersRun] { ++fibersRun; });
102 DCHECK_EQ(10000, fibersRun);
108 static const size_t kNumAllocations = 10000;
113 FiberManager fiberManager(std::make_unique<SimpleLoopController>(), opts);
115 for (
size_t iter = 0; iter < iters; ++iter) {
118 size_t fibersRun = 0;
120 for (
size_t i = 0;
i < kNumAllocations; ++
i) {
121 fiberManager.
addTask([&fibersRun] { ++fibersRun; });
126 DCHECK_EQ(10000, fibersRun);
int main(int argc, char **argv)
constexpr detail::Map< Move > move
void runBenchmark(size_t numAwaits, size_t toSend)
void init(int *argc, char ***argv, bool removeFlags)
Single-threaded task execution engine.
LoopController & loopController()
BENCHMARK(fbFollyGlobalBenchmarkBaseline)
size_t fibersPoolSize() const
FirstArgOf< F >::type::value_type await(F &&func)
FiberManager & getFiberManager(EventBase &evb, const FiberManager::Options &opts)