std::unique..._lock_until(3)
β¨ NAME β¨
okay so this page is std::unique..._lock_until(3), and it lives in the C++ Standard Libary manual β yes, thatβs the manual name, spelling and all, donβt come for me π
. The actual thing being documented is std::unique_lock::try_lock_until, and the NAME line is literally matching itself: std::unique_lock::try_lock_until - std::unique_lock::try_lock_until. iconic self-reference, no cap π.
π¦ Synopsis π¦
template< class Clock, class Duration >
bool try_lock_until( const std::chrono::time_point<Clock, Duration>&
(since C++11)
timeout_time );
the (since C++11) bit is a version tag, bestie β donβt try to pass it as an argument π.
So what does it do? It tries to lock (i.e., takes ownership of) the associated mutex. It blocks until the specified timeout_time has been reached or the lock is acquired, whichever comes first. On successful lock acquisition it returns true, otherwise it returns false. Heads up: it may block for longer than timeout_time until has been reached. π«Ά
It effectively calls mutex()->try_lock_until(timeout_time).
std::system_error is thrown if there is no associated mutex or if the mutex is already locked by the same thread.
Clock must meet the Clock requirements. The program is ill-formed if std::chrono::is_clock_v<Clock> is false. (since C++20) β
πΈ Parameters πΈ
timeout_timeβ maximum time point to block until π
π Return value π
true if the ownership of the mutex has been acquired successfully, false otherwise. periodt.
π₯ Exceptions π₯
- Any exceptions thrown by
mutex()->try_lock_until(timeout_time). - If there is no associated mutex,
std::system_errorwith an error code ofstd::errc::operation_not_permitted. - If the mutex is already locked,
std::system_errorwith an error code ofstd::errc::resource_deadlock_would_occur.
okay but fr fr, that second and third bullet are the βsomething is not givingβ errors β clock them before they clock you π
π§ Example π§
This section is incomplete. Reason: no example.
not me showing up with an example-less section ππ β but thatβs literally what the page says.
π See also π
lockβ locks (i.e., takes ownership of) the associated mutex (public member function)try_lockβ tries to lock (i.e., takes ownership of) the associated mutex without blocking (public member function)try_lock_forβ attempts to lock (i.e., takes ownership of) the associated TimedLockable mutex, returns if the mutex has been unavailable for the specified time duration (public member function)unlockβ unlocks (i.e., releases ownership of) the associated mutex (public member function)
all the little lock besties, linked and living their truth β¨
π Category π
- Todo no example
π xoxo, bestie β source: cppreference.com, version/date: 2024.06.10, and yes this is still the std::unique..._lock_until(3) page π
π¦ 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