Skip to content

stdcoroutine-3: Migrate coroutine tests from Boost.Coroutine to C++20 coroutines#6428

Draft
pratikmankawde wants to merge 5 commits intopratik/std-coro/migrate-entry-pointsfrom
pratik/std-coro/migrate-test-code
Draft

stdcoroutine-3: Migrate coroutine tests from Boost.Coroutine to C++20 coroutines#6428
pratikmankawde wants to merge 5 commits intopratik/std-coro/migrate-entry-pointsfrom
pratik/std-coro/migrate-test-code

Conversation

@pratikmankawde
Copy link
Collaborator

@pratikmankawde pratikmankawde commented Feb 25, 2026

High Level Overview of Change

Rewrite Coroutine_test.cpp and JobQueue_test.cpp to use postCoroTask() and co_await runner->suspend() instead of the old postCoro() / Coro::yield() API. After this change, zero .cpp files reference postCoro() or JobQueue::Coro.

Context of Change

This is Milestone 3 of the Boost.Coroutine → C++20 coroutines migration. Milestone 2 (pratik/std-coro/migrate-entry-points) migrated all production entry points. This milestone completes the migration of the last remaining callers — the test files.

  • Milestone 1 (pratik/std-coro/add-coroutine-primitives): Added CoroTask<T>, CoroTaskRunner, JobQueueAwaiter, postCoroTask()
  • Milestone 2 (pratik/std-coro/migrate-entry-points): Migrated all production entry points
  • Milestone 3 (pratik/std-coro/migrate-test-code): Migrated all test code
  • Milestone 4 (this PR): Delete old code and build dependencies

Coroutine_test (3 tests):

  • correct_order: postCoropostCoroTask, yield()co_await runner->suspend()
  • incorrect_order: Same migration. The post()-before-suspend() pattern remains safe because CoroTaskRunner::mutex_ serializes resume calls — the posted job's resume() blocks until the current resume() releases the lock after the coroutine suspends.
  • thread_specific_storage: shared_ptr<Coro>shared_ptr<CoroTaskRunner>, same suspend/resume pattern.

JobQueue_test (testPostCorotestPostCoroTask, 3 sub-tests):

  • Repeated post() until completion
  • Repeated resume() (synchronous) until completion
  • Shutdown rejection (postCoroTask returns nullptr)

Type of Change

  • Refactor (non-breaking change that only restructures code)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)

API Impact

  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)

Future Tasks

  • Milestone 4: Delete Coro.ipp, remove old Coro class and postCoro() from JobQueue.h, remove Boost.Coroutine from CMake/Conan dependencies

@pratikmankawde pratikmankawde added the DraftRunCI Normally CI does not run on draft PRs. This opts in. label Feb 25, 2026
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch 6 times, most recently from e807a3a to e6d78aa Compare February 26, 2026 12:13
@pratikmankawde pratikmankawde added the StdCoroutineSwitch Boost to Std Coroutine Switch label Feb 26, 2026
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from 3ee0341 to 9d79af8 Compare February 26, 2026 12:38
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from e6d78aa to 5a0e822 Compare February 26, 2026 12:39
@pratikmankawde pratikmankawde changed the title Migrate coroutine tests from Boost.Coroutine to C++20 coroutines stdcoroutine-3: Migrate coroutine tests from Boost.Coroutine to C++20 coroutines Feb 26, 2026
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from 9d79af8 to f451347 Compare February 26, 2026 13:18
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from 5a0e822 to 9445ed1 Compare February 26, 2026 13:19
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from f451347 to ecc6093 Compare February 26, 2026 14:13
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from 9445ed1 to deb4613 Compare February 26, 2026 14:13
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from ecc6093 to 7f99b08 Compare February 27, 2026 17:10
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from deb4613 to 61a87db Compare February 27, 2026 17:10
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from 7f99b08 to f7fd476 Compare February 27, 2026 17:21
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from 61a87db to 3e37424 Compare February 27, 2026 17:21
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (pratik/std-coro/migrate-entry-points@bdd3659). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@                          Coverage Diff                           @@
##             pratik/std-coro/migrate-entry-points   #6428   +/-   ##
======================================================================
  Coverage                                        ?   79.8%           
======================================================================
  Files                                           ?     850           
  Lines                                           ?   67854           
  Branches                                        ?    7562           
======================================================================
  Hits                                            ?   54135           
  Misses                                          ?   13719           
  Partials                                        ?       0           

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from f7fd476 to 75b8ba0 Compare February 27, 2026 18:39
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from 3e37424 to 00cf265 Compare February 27, 2026 18:39
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from 75b8ba0 to d9d72d5 Compare February 27, 2026 20:14
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from 00cf265 to e12ae19 Compare February 27, 2026 20:16
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch 2 times, most recently from 7c510de to 677c982 Compare February 28, 2026 10:47
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from 199ed94 to 70f96cd Compare February 28, 2026 10:47
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from 677c982 to 28fe438 Compare February 28, 2026 11:38
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from 70f96cd to ed9cf56 Compare February 28, 2026 11:38
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from 28fe438 to bdd3659 Compare February 28, 2026 12:50
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from ed9cf56 to 91daa1f Compare February 28, 2026 12:50
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-entry-points branch from bdd3659 to 666cafc Compare February 28, 2026 13:47
pratikmankawde and others added 5 commits February 28, 2026 13:47
…0 coroutines

Rewrite all test coroutine code to use postCoroTask() and co_await
runner->suspend() instead of the old postCoro() / Coro::yield() API:

- Coroutine_test: Migrate correct_order, incorrect_order, and
  thread_specific_storage tests. Replace shared_ptr<JobQueue::Coro>
  with shared_ptr<JobQueue::CoroTaskRunner>, yield() with co_await
  runner->suspend().
- JobQueue_test: Rename testPostCoro to testPostCoroTask. Migrate all
  3 sub-tests (repeated post, repeated resume, shutdown rejection)
  to the new API.

After this change, zero .cpp files reference postCoro() or
JobQueue::Coro. The old API declarations remain in JobQueue.h and
Coro.ipp for removal in the cleanup milestone.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
clang-format auto-formatting adjustments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CoroTask.h is already transitively included via JobQueue.h.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Defense-in-depth against a GCC 14 bug where reference captures in
coroutine lambdas are corrupted in the coroutine frame. The root
cause is fixed in CoroTaskRunner::init() (heap storage), but using
explicit pointer captures avoids any residual risk.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pratikmankawde pratikmankawde force-pushed the pratik/std-coro/migrate-test-code branch from 91daa1f to ddaa264 Compare February 28, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DraftRunCI Normally CI does not run on draft PRs. This opts in. StdCoroutineSwitch Boost to Std Coroutine Switch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant