{"url":"https://api.github.com/repos/stlab/stlab/releases/291588973","assets_url":"https://api.github.com/repos/stlab/stlab/releases/291588973/assets","upload_url":"https://uploads.github.com/repos/stlab/stlab/releases/291588973/assets{?name,label}","html_url":"https://github.com/stlab/stlab/releases/tag/v2.3.0","id":291588973,"author":{"login":"sean-parent","id":2279724,"node_id":"MDQ6VXNlcjIyNzk3MjQ=","avatar_url":"https://avatars.githubusercontent.com/u/2279724?v=4","gravatar_id":"","url":"https://api.github.com/users/sean-parent","html_url":"https://github.com/sean-parent","followers_url":"https://api.github.com/users/sean-parent/followers","following_url":"https://api.github.com/users/sean-parent/following{/other_user}","gists_url":"https://api.github.com/users/sean-parent/gists{/gist_id}","starred_url":"https://api.github.com/users/sean-parent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sean-parent/subscriptions","organizations_url":"https://api.github.com/users/sean-parent/orgs","repos_url":"https://api.github.com/users/sean-parent/repos","events_url":"https://api.github.com/users/sean-parent/events{/privacy}","received_events_url":"https://api.github.com/users/sean-parent/received_events","type":"User","user_view_type":"public","site_admin":false},"node_id":"RE_kwDOAiB0YM4RYUtt","tag_name":"v2.3.0","target_commitish":"main","name":"v2.3.0","draft":false,"immutable":false,"prerelease":false,"created_at":"2026-02-28T01:12:09Z","updated_at":"2026-03-01T05:28:20Z","published_at":"2026-03-01T05:28:20Z","assets":[],"tarball_url":"https://api.github.com/repos/stlab/stlab/tarball/v2.3.0","zipball_url":"https://api.github.com/repos/stlab/stlab/zipball/v2.3.0","body":"## What's Changed\r\n\r\n### `future<>::on_completion()`\r\nNew `on_completion()` interface on `future<>`. This allows notification when a future is complete. This is a low-level call used in the improved coroutine support. The completion function has a signature `void() noexcept`. It consumes a continuation slot, but does not consume the future, so if used on a move-only future, it consumes the only continuation slot, and it is UB to attach a continuation (such as with then() or recover()) after. Example:\r\n\r\n```cpp\r\n    auto f = stlab::async(default_executor, [] { return \"world!\\n\"; });\r\n    f.on_completion([]() noexcept { std::cerr << \"Hello \"; });\r\n    std::cerr << stlab::await(std::move(f));\r\n```\r\nThis will print:\r\n\r\n```\r\nHello world!\r\n```\r\n\r\n### Coroutine cancellation for `future<>.`\r\n\r\nCancellation of coroutines is now supported. When a coroutine returning a `future` awaits a `future`, the coroutine may be canceled while suspended. Example:\r\n\r\n```cpp\r\nauto coroutine(future<int> f) -> future<int> {\r\n    std::cout<< \"start\\n\";\r\n    int x = co_await std::move(f);\r\n    std::cout<< \"finish\\n\";\r\n    co_return x + 5;\r\n}\r\n\r\nint main() {\r\n    auto [p, f] = package<int(int)>(immediate_executor, std::identity{});\r\n    (void)coroutine(std::move(f)); // drop the result to cancel\r\n    p(42);  // fulfill the promise\r\n}\r\n```\r\n\r\nThis will print:\r\n\r\n```\r\nstart\r\n```\r\n\r\n### `resume_on()`\r\n\r\nThe `resume_on()` function takes a future and an executor and returns an Awaitable. This allows you to specify the execution context for resuming a coroutine. Example:\r\n\r\n```cpp\r\nauto coroutine(future<int> f) -> future<int> {\r\n    int x = co_await resume_on(main_executor, f);\r\n    x += 42; // do this on the main thread\r\n    co_return x;\r\n}\r\n```\r\n\r\nThe `resume_on()` function can be passed just an executor to immediately continue execution on the supplied executor. For both forms of resume_on(), if called in a coroutine that returns a future and all copies of the future are released, the operation may be canceled while suspended. Example:\r\n\r\n```cpp\r\n(void)coroutine(async(immediate_executor, []{ return 42; })); // drop future to cancel\r\n// might never resume from the co_await and not execute `x+= 42;`\r\n```\r\n\r\n### doctest\r\n\r\nMoved from BoostTest to [doctest](https://github.com/doctest/doctest) as part of the migration towards using `stlab/cpp-library` for this project. This improves the build times for the tests and the developer experience in VSCode/Cursor using the [C++ TestMate](https://marketplace.visualstudio.com/items?itemName=matepek.vscode-catch2-test-adapter) extension.\r\n\r\n* Improvements to coroutine support for `future<>` by @sean-parent in https://github.com/stlab/stlab/pull/590\r\n\r\n\r\n**Full Changelog**: https://github.com/stlab/stlab/compare/v2.2.0...v2.3.0","mentions_count":1}