folly icon indicating copy to clipboard operation
folly copied to clipboard

folly::coro::Task & InlineExecutor

Open Weaverzhu opened this issue 1 year ago • 0 comments

https://github.com/facebook/folly/blob/main/folly/experimental/coro/Task.h#L493

This makes the code compiled without -DNDEBUG give exception in runtime.

What if I'm using folly::InlineExecutor::instance() which is static?

What are the differences between .semi().via(&folly::InlineExecutor::instance()) and using Task with InlineExecutor

#include <folly/experimental/coro/Task.h>
#include <gtest/gtest.h>

static folly::coro::Task<void> foo() { co_return; }

folly::Future<folly::Unit> bar(folly::Unit &&) { return folly::unit; }

void some_regular_func() {
  // 1. this is ok
  foo().semi().via(&folly::InlineExecutor::instance()).thenValue(bar).get();
}

TEST(ExecutorCoroTest, test0) {
  // 2. this is not ok
  // foo().scheduleOn(&folly::InlineExecutor::instance()).start().get();

  some_regular_func();
}

Weaverzhu avatar Apr 19 '23 14:04 Weaverzhu