Commit 6b95c53d authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Rename co_schedule to co_reschedule_on_current_executor

Summary: [Folly] Rename `co_schedule` to `co_reschedule_on_current_executor`, which is longer but which more clearly identifies the behavior.

Reviewed By: lewissbaker

Differential Revision: D15215844

fbshipit-source-id: aada82e8985224608415ee5458ac8138ce13f8d0
parent 5af16267
......@@ -25,7 +25,7 @@ namespace coro {
namespace detail {
class co_schedule_t {
class co_reschedule_on_current_executor_t {
class Awaiter {
folly::Executor::KeepAlive<> executor_;
......@@ -50,7 +50,7 @@ class co_schedule_t {
friend Awaiter co_viaIfAsync(
folly::Executor::KeepAlive<> executor,
co_schedule_t) {
co_reschedule_on_current_executor_t) {
return Awaiter{std::move(executor)};
}
};
......@@ -69,12 +69,13 @@ class co_schedule_t {
// for (int i = 0; i < 1'000'000; ++i) {
// // Periodically reschedule to the executor.
// if ((i % 1024) == 1023) {
// co_await folly::coro::co_schedule;
// co_await folly::coro::co_reschedule_on_current_executor;
// }
// doSomeWork(i);
// }
// }
inline constexpr detail::co_schedule_t co_schedule;
inline constexpr detail::co_reschedule_on_current_executor_t
co_reschedule_on_current_executor;
} // namespace coro
} // namespace folly
......@@ -396,7 +396,7 @@ TEST(CollectAllRange, RangeOfNonVoid) {
using namespace std::literals::chrono_literals;
int x = count++;
if ((x % 20) == 0) {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
}
co_return x;
};
......@@ -500,7 +500,7 @@ TEST(CollectAllWindowed, ConcurrentTasks) {
[&]() -> Generator<Task<std::string>&&> {
for (int i = 0; i < 10'000; ++i) {
co_yield[](int i)->Task<std::string> {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
co_return folly::to<std::string>(i);
}
(i);
......@@ -527,7 +527,7 @@ TEST(CollectAllWindowed, WithGeneratorOfTaskOfValue) {
// Reschedule a variable number of times so that tasks may complete out of
// order.
for (int i = 0; i < index % 5; ++i) {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
}
--activeCount;
......@@ -565,7 +565,7 @@ TEST(CollectAllWindowed, WithGeneratorOfTaskOfVoid) {
auto makeTask = [&]() -> folly::coro::Task<void> {
auto count = ++activeCount;
CHECK_LE(count, maxConcurrency);
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
--activeCount;
++completedCount;
};
......@@ -591,7 +591,7 @@ TEST(CollectAllWindowed, VectorOfVoidTask) {
int count = 0;
auto makeTask = [&]() -> folly::coro::Task<void> {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
++count;
};
......@@ -611,7 +611,7 @@ TEST(CollectAllWindowed, VectorOfValueTask) {
int count = 0;
auto makeTask = [&](int i) -> folly::coro::Task<std::unique_ptr<int>> {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
++count;
co_return std::make_unique<int>(i);
};
......@@ -640,11 +640,11 @@ TEST(CollectAllWindowed, PartialFailure) {
co_yield[](int i)->folly::coro::Task<int> {
using namespace std::literals::chrono_literals;
if (i == 3) {
co_await folly::coro::co_schedule;
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
co_await folly::coro::co_reschedule_on_current_executor;
throw ErrorA{};
} else if (i == 7) {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
throw ErrorB{};
}
co_return i;
......@@ -671,11 +671,11 @@ TEST(CollectAllTryWindowed, PartialFailure) {
co_yield[](int i)->folly::coro::Task<int> {
using namespace std::literals::chrono_literals;
if (i == 3) {
co_await folly::coro::co_schedule;
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
co_await folly::coro::co_reschedule_on_current_executor;
throw ErrorA{};
} else if (i == 7) {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
throw ErrorB{};
}
co_return i;
......@@ -707,7 +707,7 @@ TEST(CollectAllTryWindowed, GeneratorFailure) {
++active;
++started;
for (int j = 0; j < (i % 3); ++j) {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
}
--active;
};
......
......@@ -25,13 +25,13 @@
#include <folly/portability/GTest.h>
TEST(Task, CoSchedule) {
TEST(Task, CoRescheduleOnCurrentExecutor) {
std::vector<int> results;
folly::coro::blockingWait(folly::coro::collectAll(
folly::coro::co_invoke([&]() -> folly::coro::Task<void> {
for (int i = 0; i <= 10; i += 2) {
if (i == 6) {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
}
results.push_back(i);
}
......@@ -39,7 +39,7 @@ TEST(Task, CoSchedule) {
folly::coro::co_invoke([&]() -> folly::coro::Task<void> {
for (int i = 1; i < 10; i += 2) {
if (i == 7) {
co_await folly::coro::co_schedule;
co_await folly::coro::co_reschedule_on_current_executor;
}
results.push_back(i);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment