Skip to content

Commit 33c9ffb

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Use co_withExecutor in folly/docs/examples/folly/ExecutorGuide.cpp +5
Summary: `yourTask().scheduleOn(ex)` is deprecated in favor of `co_withExecutor(ex, yourTask())` For `Task`, both forms are equivalent, but `co_withExecutor` makes it much easier to migrate to the [lifetime-safe `NowTask`](https://fb.prod.workplace.com/groups/192968587972839/posts/1784449738824708) (and upcoming `SafeTask`). Thanks to [C++ ADL](https://en.cppreference.com/w/cpp/language/adl.html), you can write simply `co_withExecutor`; it does not *have* to be qualified with the namespace `folly::coro::`. [This post](https://fb.prod.workplace.com/groups/192968587972839/posts/1693720697897613) explains the safety benefits of `co_withExecutor`. Moreover, the new name better aligns with the other `folly::coro` protocol of `co_withCancellation()`. This diff generated with: ``` fbpython fbcode/scripts/rbarnes/schedule_on_fixer.py ``` - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: meyering Differential Revision: D77751702 fbshipit-source-id: fda192e43473821ec7862e861323c217c8bedfdb
1 parent b532ad3 commit 33c9ffb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

third-party/folly/src/folly/docs/examples/folly/ExecutorGuide.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int main() {
6666
folly::coro::Task t = foo(baton, 111);
6767

6868
std::cout << "2. Assigning an Executor.\n";
69-
folly::coro::TaskWithExecutor te = std::move(t).scheduleOn(executor);
69+
folly::coro::TaskWithExecutor te = co_withExecutor(executor, std::move(t));
7070

7171
std::cout << "3. Starting the Task.\n"
7272
<< " This is where the Coroutine calls executor.add().\n";

0 commit comments

Comments
 (0)