std::corout...ndle::resume(3)

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

🌸 NAME

okay so bestie, we're cracking open the page header std::corout...ndle::resume(3) from the manual named C++ Standard Libary β€” yes, that spelling is exactly what's on the page πŸ’–. And the NAME section is giving β€œsame string twice” energy, no cap:

  • std::coroutine_handle::operator(),std::coroutine_handle::resume β€” std::coroutine_handle::operator(),std::coroutine_handle::resume

✨ Synopsis

The formatting on this page is doing a little chaos dance, but here are the exact signatures and labels, bestie:

Member of other specializations
void operator()() const;
void resume() const;
(1) (since C++20)

Member of specialization
std::coroutine_handle<std::noop_coroutine_promise>
constexpr void operator()() const noexcept;
constexpr void resume() const noexcept;
(2) (since C++20)

So overload (1) is the β€œMember of other specializations” flavor: it resumes the execution of the coroutine to which *this refers, or does nothing if the coroutine is a no-op coroutine. Overload (2) is the std::coroutine_handle<std::noop_coroutine_promise> specialization: it does nothing. Not a little nothing. Literally nothing. The way that’s iconic for a no-op coroutine promise? Obsessed 🫢.

πŸ’€ Behavior is undefined if *this does not refer to suspended coroutine, or the coroutine is not a no-op coroutine and suspended at its final suspend point. A concurrent resumption of the coroutine may result in a data race. This is the part where you do not send it β€” undefined behavior is not the vibe, fr fr.

Resumption of a coroutine on an execution agent other than the one on which it was suspended has implementation-defined behavior unless each execution agent either is a thread represented by std::thread or std::jthread, or is the thread executing main. That’s a whole mouthful but every word matters πŸ’….


πŸŽ€ Parameters

(none) β€” literally no parameters, bestie. The page says (none) and I’m not gonna invent any.


πŸ’– Return value

(none) β€” same energy. No return value. Periodt.


πŸ”₯ Exceptions

If an exception is thrown from the execution of the coroutine, the exception is caught and unhandled_exception is called on the coroutine's promise object. If the call to unhandled_exception throws or rethrows an exception, that exception is propagated. Catching and rethrowing tea, handled exactly like the page says 🧚.


πŸ¦‹ Notes

A coroutine that is resumed on a different execution agent should avoid relying on consistent thread identity throughout, such as holding a mutex object across a suspend point. That’s the self-care note for your coroutine’s thread identity, iykyk 🌸.


🌈 Example

This section is incomplete.

  • Reason: no example

No example bestie, the page is leaving us on read 😭.


πŸ‘€ See also

  • destroy β€” destroys a coroutine; (C++20) (public member function)

🏷️ Category:

  • Todo no example

byeee 🫢✨ source/version/date sign-off: this page comes from http://cppreference.com, dated 2024.06.10, and the page header is std::corout...ndle::resume(3) β€” mwah πŸ’…πŸ’œ.

πŸ“¦ where this page comes from