xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_MutexLock()

Obtains a permanent lock on a Mutex.

Syntax

HB_MutexLock( <pMutexHandle> ) --> lSuccess

Arguments

<pMutexHandle>
This is the handle of the Mutex to lock. It is the return value of HB_MutexCreate().

Return

The function returns .T. (true) when the Mutex is locked, and .F. (false) when an error occurs.

Description

Function HB_MutexLock() locks the Mutex <pMutexHandle> for the current thread. If the Mutex is already locked by another thread, the current thread is suspended. That is, HB_MutexLock() waits infinitely and returns only when a lock is obtained.

If the infinite wait period is not desired, a thread can call HB_MutexTryLock() to check if the Mutex can be locked, or HB_MutexTimeoutLock(), to restrict the wait period to a specified amount of time.

A locked Mutex must be unlocked with HB_MutexUnlock() to grant other threads access to the Mutex protected program code.

Refer to function HB_MutexCreate() for more information on Mutexes.

Info

See also:GetCurrentThread(), GetThreadID(), HB_MutexCreate(), HB_MutexTimeoutLock(), HB_MutexTryLock(), HB_MutexUnlock(), JoinThread(), Notify(), StartThread(), Subscribe()
Category: Multi-threading functions , Mutex functions , xHarbour extensions
Source:vm\thread.c
LIB:xhbmt.lib
DLL:xhbmtdll.dll


Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe