std::shared...y_lock_until(3)
π std::shared...y_lock_until(3) π
okay so welcome to the C++ Standard Libary manual, bestie β yes, "Libary" is exactly how it's spelled here, and we are not fixing it. This page is all about std::shared_timed_mutex::try_lock_until, and it's giving deadline energy fr fr.
πΈ NAME πΈ
std::shared_timed_mutex::try_lock_untilβstd::shared_timed_mutex::try_lock_until, bestie. That's the member function, that's the whole name section, periodt.
β¨ Synopsis β¨
Here's the synopsis as it shows up on the page, line breaks and all:
template< class Clock, class Duration >
bool try_lock_until( const std::chrono::time_point<Clock, Duration>&
(since C++14)
timeout_time );
Okay so what does it actually do? It tries to lock the mutex. It blocks until the specified timeout_time has been reached (that's the timeout) or the lock is acquired (meaning it owns the mutex), whichever comes first. On successful lock acquisition it returns true, otherwise it returns false.
If timeout_time has already passed, this function behaves like try_lock().
Clock must meet the Clock requirements. The program is ill-formed if std::chrono::is_clock_v<Clock> is false. (since C++20)
The standard recommends that the clock tied to timeout_time be used, in which case adjustments of the clock may be taken into account. Thus, the duration of the block might be more or less than timeout_time - Clock::now() at the time of the call, depending on the direction of the adjustment and whether it is honored by the implementation. The function also may block until after timeout_time has been reached due to process scheduling or resource contention delays. Scheduling really said "I'll do what I want" π.
As with try_lock(), this function is allowed to fail spuriously and return false even if the mutex was not locked by any other thread at some point before timeout_time. So a false does not always mean someone else had it, bestie.
Prior unlock() operation on the same mutex synchronizes-with (as defined in std::memory_order) this operation if it returns true.
If try_lock_until is called by a thread that already owns the mutex in any mode (shared or exclusive), the behavior is undefined. That's the danger zone, bestie β do not do that.
π«Ά Parameters π«Ά
timeout_timeβ maximum time point to block until.
π Return value π
trueif the lock was acquired successfully, otherwisefalse.
π Exceptions π
Any exception thrown by timeout_time (clocks, time points, and durations provided by the standard library never throw). That's the whole exception story, ngl.
π Example π
This section is incomplete Reason: no example
π See also π
lockβ locks the mutex, blocks if the mutex is not available (public member function).try_lockβ tries to lock the mutex, returns if the mutex is not available (public member function).try_lock_forβ tries to lock the mutex, returns if the mutex has been unavailable for the specified timeout duration (public member function).unlockβ unlocks the mutex (public member function).- C documentation for
mtx_timedlock.
π§ Category π§
* Todo no exampleβ yeah, that's the category tag. The page is filed under Todo no example.
okay bye bestie, stay locked and loaded π source: http://cppreference.com β’ date/version: 2024.06.10
π¦ 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