std::promis...thread_exit(3)

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

okay so bestie, welcome to std::promis...thread_exit(3) β€” the manual page from the C++ Standard Libary manual. Yes, that's the manual name, keep the vibe. This page is about std::promise::set_exception_at_thread_exit, and we're gonna get into it. πŸ’…

πŸ’– NAME πŸ’–

std::promise::set_exception_at_thread_exit β€” that's the name. Also, the page literally repeats it: std::promise::set_exception_at_thread_exit. It's giving β€œsay it twice so they know you're serious.” ✨

✨ Synopsis ✨

Here's the signature, bestie:

void set_exception_at_thread_exit( std::exception_ptr p );

(since C++11) πŸŽ€

So what does it do? It stores the exception pointer p into the shared state without making the state ready immediately. The state gets made ready when the current thread exits, after all variables with thread-local storage duration have been destroyed. lowkey a lil delayed-reaction vibe. πŸ’…

The operation behaves as though set_value, set_exception, set_value_at_thread_exit, and set_exception_at_thread_exit acquire a single mutex associated with the promise object while updating the promise object. Not me listing all four, but yes, all four. 🫢

An exception is thrown if there is no shared state or if the shared state already stores a value or exception. 🚨

Calls to this function do not introduce data races with calls to get_future (therefore they need not synchronize with each other). no cap, that's the actual note. 🌸

🫢 Parameters 🫢

  • p β€” exception pointer to store. The behavior is undefined if p is nullptr. 🚨

πŸŽ€ Return value πŸŽ€

(none) β€” literally none, bestie. πŸ’–

πŸ’€ Exceptions πŸ’€

std::future_error on the following conditions:

  • *this has no shared state. The error code is set to no_state.
  • The shared state already stores a value or exception. The error code is set to promise_already_satisfied.

🌈 Example 🌈

This section is incomplete. Reason: no example. 😭

Not me showing up to the example section and it's empty β€” iconic empty-section behavior. 🫠

πŸ¦‹ See also πŸ¦‹

  • set_exception sets the result to indicate an exception (public member function). ✨

πŸ“ Category πŸ“

  • Todo no example. πŸ’€

source/version + date, wrapped in a cute lil sign-off: this page is from http://cppreference.com, dated 2024.06.10, and it's the std::promis...thread_exit(3) page. mwah πŸ’‹πŸ«Ά

πŸ“¦ where this page comes from