Skip to content

class recursive_mutex

徐辰 edited this page Apr 8, 2014 · 3 revisions
  • Member functions
    • recursive_mutex()
    • recursive_mutex( const recursive_mutex& ) = delete
      Constructs the mutex. The mutex is in unlocked state after the call.
      Copy constructor is deleted.
    • void lock()
      Locks the mutex. If another fiber has already locked the mutex, a call to lock will block execution until the lock is acquired.
      A fiber may call lock on a recursive mutex repeatedly. Ownership will only be released after the fiber makes a matching number of calls to unlock.
    • bool try_lock()
      Tries to lock the mutex. Returns immediately. On successful lock acquisition returns true, otherwise returns false.
      If try_lock is called by a fiber that already owns the mutex, it always returns true.
      A fiber may call try_lock on a recursive mutex repeatedly. Successful calls to try_lock increment the ownership count: the mutex will only be released after the fiber makes a matching number of calls to unlock.
    • void unlock()
      Unlocks the mutex if its level of ownership is 1 (there was exactly one more call to lock() than there were calls to unlock() made by this fiber), reduces the level of ownership by 1 otherwise.
      The mutex must be locked by the current fiber of execution, otherwise an operation_not_permitted error condition may be thrown.
Clone this wiki locally