std::shared...ex::try_lock(3)

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

πŸ’… std::shared_timed_mutex::try_lock πŸ’…

okay bestie, this is the page for std::shared_timed_mutex::try_lock β€” title std::shared...ex::try_lock(3), manual name C++ Standard Libary (yes, that spelling is exactly what the header says). Welcome to the group chat. πŸ’–

🌸 NAME 🌸

std::shared_timed_mutex::try_lock - std::shared_timed_mutex::try_lock

✨ Synopsis ✨

bool try_lock();  (since C++14)

So it’s giving β€œtry to lock the mutex, but don’t wait around.” It returns immediately. On successful lock acquisition it returns true, otherwise it returns false. πŸŽ€

This function is allowed to fail spuriously and return false even if the mutex is not currently locked by any other thread. not a typo, bestie β€” spurious failure is legal. 😭

If try_lock is called by a thread that already owns the mutex in any mode (shared or exclusive), the behavior is undefined. undefined behavior, do not collect $200, do not pass go. πŸ’€

Prior unlock() operation on the same mutex synchronizes-with (as defined in std::memory_order) this operation if it returns true. Note that prior lock() does not synchronize with this operation if it returns false. πŸ¦‹

πŸŽ€ Parameters πŸŽ€

(none)

πŸ“ Return value πŸ“

true if the lock was acquired successfully, otherwise false.

πŸ’œ Exceptions πŸ’œ

Throws nothing.

🌈 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_for β€” tries to lock the mutex, returns if the mutex has been unavailable for the specified timeout duration (public member function)
  • try_lock_until β€” tries to lock the mutex, returns if the mutex has been unavailable until specified time point has been reached (public member function)
  • unlock β€” unlocks the mutex (public member function)
  • C documentation for mtx_trylock

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

  • * Todo no example

mwah πŸ’‹ this page is from http://cppreference.com, version/date 2024.06.10 β€” catch you in the group chat, bestie 🫢✨

πŸ“¦ where this page comes from