Skip to content

Commit

Permalink
Test async stack tracing for fibers::Baton
Browse files Browse the repository at this point in the history
Summary: Make sure async stack traces are tracked for coroutines awaiting fibers::Baton.

Reviewed By: mbucko

Differential Revision: D66720217

fbshipit-source-id: 3a944ff6c7b5e0ef824d5d0ff37fd606923a16da
  • Loading branch information
Pranav Thulasiram Bhat authored and facebook-github-bot committed Dec 4, 2024
1 parent 81a2550 commit a046686
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions folly/coro/test/SuspendedStackTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,26 @@ CO_TEST(SuspendedStacksTest, testBaton) {
expectSuspendedFrames(0);
}

CO_TEST(SuspendedStacksTest, testFibersBaton) {
auto currentDepth =
(co_await folly::coro::co_current_async_stack_trace).size();
auto* ex = co_await folly::coro::co_current_executor;

expectSuspendedFrames(0);

folly::fibers::Baton b;
waitOn<coroDepth>(b).scheduleOn(ex).start();
co_await folly::coro::co_reschedule_on_current_executor;
expectSuspendedFrames(1, currentDepth + coroDepth);

// Only one fiber/coro can wait on a fibers::Baton

b.post();
co_await folly::coro::co_reschedule_on_current_executor;

expectSuspendedFrames(0);
}

CO_TEST(SuspendedStacksTest, testLock) {
auto currentDepth =
(co_await folly::coro::co_current_async_stack_trace).size();
Expand Down

0 comments on commit a046686

Please sign in to comment.