std::shared...:wait_until(3)
π 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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms