std::execut...ure_started(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

okay bestie, welcome to the std::execut...ure_started(3) page from the C++ Standard Libary β€” yes, that's the manual name, we're rolling with it πŸ’–

  • std::execution::ensure_started β€” and the description is literally std::execution::ensure_started again. Self-titled queen behavior, honestly πŸ‘‘

✨ Synopsis ✨

bestie, here's the whole vibe in code form πŸ‘‡

          Defined in header <execution>
          execution::sender auto ensure_started(

              execution::sender auto sender       (since C++26)

          );

That's the since C++26 glow-up, no cap ⭐

πŸ’… Parameters πŸ’…

  • sender β€” the input sender, of which the stopped channel is mapped into err 🫢

πŸŽ€ Return value πŸŽ€

Returns a sender which completes when the provided sender completes and sends values equivalent to those of the provided sender. Cute, consistent, iconic πŸ’–

πŸ¦‹ Notes πŸ¦‹

  • Once ensure_started returns, it is known that the provided sender has been connected and start has been called on the resulting operation state. In other words, the work described by the provided sender has been submitted for execution on the appropriate execution resources. Slay, it's already in motion ✨
  • If the returned sender is destroyed before execution::connect() is called, or if execution::connect() is called but the returned operation-state is destroyed before execution::start() is called, then a stop-request is sent to the eagerly launched operation and the operation is detached and will run to completion in the background. Lowkey important 🫢
  • In such a case, the operation's result will be discarded when it is eventually complete. Bye-bye result, we hardly knew ye 😭
  • Note that the application will need to make sure that resources are kept alive in the case that the operation detaches (e.g. by holding a std::shared_ptr to those resources). This is the "keep your faves alive" rule fr fr πŸ’€
⚠️ detach means background business β€” keep those resources alive, bestie, or it's giving undefined chaos energy πŸ’…

shoutout to http://cppreference.com, dated 2024.06.10, for this std::execut...ure_started(3) moment πŸŒˆπŸ’–βœ¨

πŸ“¦ where this page comes from