std::packag...:operator()(3)

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

πŸ’… std::packaged_task::operator() πŸ’…

okay so bestie, this is the std::packag...:operator()(3) page from the C++ Standard Libary manual, and it’s literally all about the operator() for std::packaged_task. no cap, it’s giving β€œcall the stored task, update the shared state, unblock the girlies waiting on it” energy. πŸ¦‹βœ¨


✨ NAME ✨

std::packaged_task::operator() - std::packaged_task::operator() πŸ’–

πŸŽ€ Synopsis πŸŽ€

void operator()( ArgTypes... args );  (since C++11)

okay so it calls the stored task as if by INVOKE<R>(f, args...), where f is the stored task. πŸ‘‘

The return value of the task or any exceptions thrown are stored in the shared state. The shared state is made ready and any threads waiting for this are unblocked. literally everyone waiting gets the notification. πŸ””

🌸 Parameters 🌸

  • args β€” the parameters to pass on invocation of the stored task. 🫢

πŸ“ Return value πŸ“

(none) β€” yeah, it’s a void situation, bestie. πŸ’€

πŸ”₯ Exceptions πŸ”₯

std::future_error on the following error conditions:

  • The stored task has already been invoked. The error category is set to promise_already_satisfied. 😭
  • *this has no shared state. The error category is set to no_state. πŸ™ˆ

🧚 Example 🧚

This section is incomplete Reason: no example

πŸ‘‘ Defect reports πŸ‘‘

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • LWG 2142 β€” applied to C++11
    • Behavior as published: a successful call to operator() synchronized with a call to any member function of std::future or std::shared_future that share their shared state with *this
    • Correct behavior: no additional synchronization guarantees other than what is already provided by shared state

🌈 See also 🌈

  • make_ready_at_thread_exit β€” executes the function ensuring that the result is ready only once the current thread exits (public member function). πŸ’…

πŸ¦‹ Category πŸ¦‹

  • Todo no example

xoxo πŸ’– this has been your std::packag...:operator()(3) moment β€” source: http://cppreference.com, version/date: 2024.06.10 ✨

πŸ“¦ where this page comes from