Login
You're viewing the code4lib.social public feed.
  • Nov 26, 2026, 12:21 PM

    Let's talk about asynchronous I/O and cancellation.

    Often times when you work with asynchronous tasks, you want to be able to cancel tasks.

    apt-core's approach is to

    1. introduce a transparent context object that gets carried around by a promise's await_transform() - you can co_await a special value to get the current one.

    2. surface cancellation in normal flow: Any operation that returns an std::expected<T,E> where there exists an E::Cancelled can be cancelled.

    💬 1🔄 0⭐ 0

Replies

  • Nov 26, 2026, 12:22 PM

    So a cancelled coroutine is resumed normally with a `Cancelled` error and needs to shut itself down cleanly.

    This avoids all the classic baggage surrounding cancellation tokens with callbacks, turning cancellation into a straightforward concept.

    💬 0🔄 0⭐ 0