Releases: stlab/stlab
Release list
v2.3.0
What's Changed
future<>::on_completion()
New 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:
auto f = stlab::async(default_executor, [] { return "world!\n"; });
f.on_completion([]() noexcept { std::cerr << "Hello "; });
std::cerr << stlab::await(std::move(f));This will print:
Hello world!
Coroutine cancellation for future<>.
Cancellation of coroutines is now supported. When a coroutine returning a future awaits a future, the coroutine may be canceled while suspended. Example:
auto coroutine(future<int> f) -> future<int> {
std::cout<< "start\n";
int x = co_await std::move(f);
std::cout<< "finish\n";
co_return x + 5;
}
int main() {
auto [p, f] = package<int(int)>(immediate_executor, std::identity{});
(void)coroutine(std::move(f)); // drop the result to cancel
p(42); // fulfill the promise
}This will print:
start
resume_on()
The 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:
auto coroutine(future<int> f) -> future<int> {
int x = co_await resume_on(main_executor, f);
x += 42; // do this on the main thread
co_return x;
}The 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:
(void)coroutine(async(immediate_executor, []{ return 42; })); // drop future to cancel
// might never resume from the co_await and not execute `x+= 42;`doctest
Moved from BoostTest to 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 extension.
- Improvements to coroutine support for
future<>by @sean-parent in #590
Full Changelog: v2.2.0...v2.3.0
v2.2.0
What's Changed
- Changed repo to stlab/stlab to better support CPM.cmake with installs.
- Added
cmake --installsupport usingstlab/cpp-library. - Release version is now pickup from the git tag via cpp-library.
Bug Fix
- Fixed a bug in system_timer that could crash on exit when using libdispatch.
Full Changelog: v2.1.4...v2.2.0
v2.1.4
On Windows, the static singleton executors were being created in a member function templated on the task type. This was causing unnecessary thread pools to get constructed. Moved instances to the .cpp file to make it simpler to share across DLLs (open issue is to normalize the various implementations).
What's Changed
- Fixing windows singleton executors by @sean-parent in #580
Full Changelog: v2.1.3...v2.1.4
v2.1.3
- Updated dependencies.
- Tests are now only registered if the project is top-level.
v2.1.2
Some minor fixes to allow building with \permissive in MSVC under C++17.
v2.1.1
v2.1.0
What's Changed
- Make task pool size configurable by @bmedina in #571
- Adding dependency to new enum_ops library. by @sean-parent in #572
New Contributors
Full Changelog: v2.0.2...v2.1.0
v2.0.2
What's Changed
- Fix STLAB_CPP_VERSION and use in future.hpp. by @venik in #567
- Fixing include paths for dependencies. by @sean-parent in #569
- Updating CPM and version for 2.0.2 release by @sean-parent in #570
New Contributors
Full Changelog: v2.0.1...v2.0.2
v2.0.1
What's Changed
- Adding test for CMake install. by @sean-parent in #566
- Fixed CMake install
- Fixed library version number in CMake and version.hpp
Full Changelog: v2.0.0...v2.0.1
v2.0.0
What's Changed
- Factored out the copy-on-write library into a stand-alone library.
- Adds a call to pre_exit() on each example using default_executor by @fpelliccioni in #500
- new API: bool packaged_task::canceled() const by @KevinHopps in #498
- Changes to support C++14 and fixed missing include file (#501) by @sean-parent in #503
- Fix name conflict with boost math in Boost <= 1.76 by @fpelliccioni in #499
- Changed CMake paths to be robust to subprojects by @laserallan in #507
- Fixes to futures by @sean-parent in #505
- Fix typo from main_scheduler_type to main_executor_type by @nickpdemarco in #516
- Revisit Reduce by @sean-parent in #521
- Add check for C++20, make ambiguous case assume 23 by @nickpdemarco in #522
- Restore Qt5 compatibility by @touraill-adobe in #524
- Minor comment fix by @sean-parent in #526
- Requiring executor tasks are noexcept. by @sean-parent in #528
- Removing use of boost::variant and optional from stlab now that it has moved to C++17 by @thinlang in #531
- Updating documentation and documentation system to hyde 2.0 by @sean-parent in #534
- Some minor fixes by @sean-parent in #537
- General Cleanup by @sean-parent in #539
- Fix to use after move by @sean-parent in #540
- namespace version bump by @sean-parent in #541
- Update layout-terminology.md by @sean-parent in #542
- Update layout-terminology.md by @sean-parent in #543
- add move implementation which asserts on providing const argument by @dhaibatc in #544
- Static Analysis by @sean-parent in #546
- Nix an unused matrix element by @dabrahams in #548
- Update code base to pass clang-tidy by @sean-parent in #552
- Reworking reduction by @sean-parent in #551
- Restructuring to simplify Windows build (and all builds) by @sean-parent in #553
- Minor fixes to await and await docs. by @sean-parent in #555
- Add STLAB_BUILD_LIBRARY CMake option to build a library by @gbottesi in #556
- always_true is defined statically in 2 tests. by @geoffoxholm in #561
- Use weaker memory ordering for COW count. by @sean-parent in #563
New Contributors
- @KevinHopps made their first contribution in #498
- @laserallan made their first contribution in #507
- @touraill-adobe made their first contribution in #524
- @thinlang made their first contribution in #531
- @dhaibatc made their first contribution in #544
- @gbottesi made their first contribution in #556
- @geoffoxholm made their first contribution in #561
Full Changelog: v1.7.1...v2.0.0