
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Novlib 3.30 Online Reference - <b> semvaldec()</b>
[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
SemValDec()
------------------------------------------------------------------------------
Purpose:
Decrement a semaphore value by 1.
Syntax:
bResult = SemValDec( dwSemID, wTimeOut )
Parameters:
dwSemID The semaphore ID number.
wTimeOut The timeout period in seconds.
Returns:
A boolean value (TRUE or FALSE).
Description:
SemValDec() returns TRUE if the value of the semaphore specified
by ID number dwSemID is decremented successfully.
Returns FALSE if not, or if an error occurs.
The timeout parameter wTimeOut causes SemValDec() to wait on an
unavailable semaphore for wTimeOut seconds. If the semaphore becomes free
within that time SemValDec() will return TRUE. Otherwise it will
timeout and return FALSE.
Semaphore values may be in the range -127 to 127. Attempts to decrement a
semaphore value below 0 result in SemValDec() waiting the timeout
period wTimeOut before returning FALSE. In the meantime, if another user
has incremented the semaphore, SemValDec() will then decrement the
semaphore and return TRUE.
Example:
// To open a semaphore called "UPDATE_SEM" with an initial value 24 and
// decrement its value by one with a maximum wait of 15 seconds:
dwSemID = SemOpen( "UPDATE_SEM", 24 )
if ( NWErrorGet() = 0 )
if ( SemValDec( dwSemID, 15 ) )
? "Semaphore decremented successfully"
endif
endif
Notes:
If FALSE is returned, check NWErrorGet().
Note for CA-Clipper:
IMPORTANT - both positive and negative values are valid semaphore handles,
except the value NOVERRLONG. Valid semaphore handles can be in the range
-2147483647 to +2147483647.
See Also: SemValInc() SemValGet()
Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson