Skip to content

Releases: stlab/stlab

v2.3.0

Choose a tag to compare

@sean-parent sean-parent released this 01 Mar 05:28
e126676

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.

Full Changelog: v2.2.0...v2.3.0

v2.2.0

Choose a tag to compare

@sean-parent sean-parent released this 19 Dec 23:44
7abde9e

What's Changed

  • Changed repo to stlab/stlab to better support CPM.cmake with installs.
  • Added cmake --install support using stlab/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

Choose a tag to compare

@sean-parent sean-parent released this 21 Oct 20:14
07b51b5

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

Full Changelog: v2.1.3...v2.1.4

v2.1.3

Choose a tag to compare

@sean-parent sean-parent released this 01 Oct 17:20
85a52e7
  • Updated dependencies.
  • Tests are now only registered if the project is top-level.

v2.1.2

Choose a tag to compare

@sean-parent sean-parent released this 23 Sep 22:51
44adee7

Some minor fixes to allow building with \permissive in MSVC under C++17.

v2.1.1

Choose a tag to compare

@sean-parent sean-parent released this 29 Aug 01:18
2c9912b

What's Changed

Full Changelog: v2.1.0...v2.1.1

v2.1.0

Choose a tag to compare

@sean-parent sean-parent released this 27 Aug 22:45
cbcc720

What's Changed

New Contributors

Full Changelog: v2.0.2...v2.1.0

v2.0.2

Choose a tag to compare

@sean-parent sean-parent released this 04 Aug 21:26
fb838a1

What's Changed

New Contributors

Full Changelog: v2.0.1...v2.0.2

v2.0.1

Choose a tag to compare

@sean-parent sean-parent released this 04 Jul 03:58
3dacc6f

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

Choose a tag to compare

@sean-parent sean-parent released this 28 Jun 01:05

What's Changed

New Contributors

Full Changelog: v1.7.1...v2.0.0