std::shared...:wait_until(3)

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

πŸ’… std::shared_future::wait_until(3)

okay so this is the C++ Standard Libary man page for std::shared_future::wait_until, section 3 β€” yes, β€œLibary” is literally how the header spells it, don’t come for me πŸ’€ β€” and bestie, the whole vibe is β€œblock until the result shows up or the deadline says time’s up.” πŸ•°οΈβœ¨


🌸 NAME 🌸

std::shared_future::wait_until β€” std::shared_future::wait_until. yeah, the name is the name, she said what she said πŸ’…


✨ Synopsis ✨

template< class Clock, class Duration >
std::future_status wait_until( const
std::chrono::time_point<Clock,Duration>& timeout_time ) const;

(since C++11) β€” this overload has been around since C++11, bestie. 🫢

wait_until waits for a result to become available. It blocks until the specified timeout_time has been reached or the result becomes available, whichever comes first. The return value tells you why wait_until returned. πŸ‘‘

If the future is the result of a call to async that used lazy evaluation, this function returns immediately without waiting. no cap, it just peaces out 🫑

The behavior is undefined if valid() is false before the call to this function, or if Clock does not meet the Clock requirements. like, do not play with that, fr fr 😭 And since C++20, the program is ill-formed if std::chrono::is_clock_v<Clock> is false.


πŸŽ€ Parameters πŸŽ€

  • timeout_time β€” maximum time point to block until. that’s the deadline, bestie ⏳

🫢 Return value 🫢

The return value is one of these future_status constants, and here’s the tea: β˜•βœ¨

  • future_status::deferred β€” the shared state contains a deferred function using lazy evaluation, so the result will be computed only when explicitly requested.
  • future_status::ready β€” the result is ready.
  • future_status::timeout β€” the timeout has expired.

😭 Exceptions 😭

Any exception thrown by clock, time_point, or duration during the execution β€” clocks, time points, and durations provided by the standard library never throw. so at least the standard-library ones are chill 🧚


🧠 Notes 🧠

The implementations are encouraged to detect the case when valid() == false before the call and throw a std::future_error with an error condition of future_errc::no_state. encouraged, not required β€” iykyk πŸ‘€

The standard recommends that the clock tied to timeout_time be used to measure time; that clock is not required to be a monotonic clock. There are no guarantees regarding the behavior of this function if the clock is adjusted discontinuously, but the existing implementations convert timeout_time from Clock to std::chrono::system_clock and delegate to POSIX pthread_cond_timedwait so that the wait honors adjustments to the system clock, but not to the user-provided Clock. In any case, the function also may wait for longer than until after timeout_time has been reached due to scheduling or resource contention delays. basically: clocks are messy and scheduling said β€œnot today” πŸ’€


πŸ§ͺ Example πŸ§ͺ

This section is incomplete.

Reason: no example. not me showing up with no example 😭


πŸ‘€ See also πŸ‘€

  • wait β€” waits for the result to become available (public member function).
  • wait_for β€” waits for the result, returns if it is not available for the specified timeout duration (public member function).

πŸ—‚οΈ Category: πŸ—‚οΈ

  • Todo no example.

mwah πŸ’‹ this page came from http://cppreference.com, dated 2024.06.10, and the man page id is std::shared...:wait_until(3). slay, periodt. πŸŽ€πŸ”₯

πŸ“¦ where this page comes from