try_lock_mutexT_try_lock_mutexTryLockMutexTryLockMutextry_lock_mutex (算子)

名称

try_lock_mutexT_try_lock_mutexTryLockMutexTryLockMutextry_lock_mutex — Lock a mutex synchronization object.

签名

try_lock_mutex( : : MutexHandle : Busy)

Herror T_try_lock_mutex(const Htuple MutexHandle, Htuple* Busy)

void TryLockMutex(const HTuple& MutexHandle, HTuple* Busy)

Hlong HMutex::TryLockMutex() const

static void HOperatorSet.TryLockMutex(HTuple mutexHandle, out HTuple busy)

int HMutex.TryLockMutex()

def try_lock_mutex(mutex_handle: HHandle) -> int

描述

try_lock_mutextry_lock_mutexTryLockMutexTryLockMutexTryLockMutextry_lock_mutex behaves identically to lock_mutexlock_mutexLockMutexLockMutexLockMutexlock_mutex, except that it does not block the calling thread if the mutex is already locked by another thread but returns immediately. The state of the mutex before trying to lock it is returned in BusyBusyBusyBusybusybusy. 1 indicates that the mutex was already locked before calling try_lock_mutextry_lock_mutexTryLockMutexTryLockMutexTryLockMutextry_lock_mutex, 0 that the mutex was unlocked (signaled).

执行信息

参数

MutexHandleMutexHandleMutexHandleMutexHandlemutexHandlemutex_handle (输入控制)  mutex HMutex, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Mutex synchronization object.

BusyBusyBusyBusybusybusy (输出控制)  number HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Mutex already locked?

结果

If the mutex handle is valid, the operator try_lock_mutextry_lock_mutexTryLockMutexTryLockMutexTryLockMutextry_lock_mutex 返回 2 ( H_MSG_TRUE )。如有必要,则抛出异常。

可能的前趋

create_mutexcreate_mutexCreateMutexCreateMutexCreateMutexcreate_mutex

可能的后继

unlock_mutexunlock_mutexUnlockMutexUnlockMutexUnlockMutexunlock_mutex

另见

lock_mutexlock_mutexLockMutexLockMutexLockMutexlock_mutex

模块

基础