NAME
Win32::Semaphore - Use Win32 semaphore objects from Perl
SYNOPSIS require Win32::Semaphore;
$sem = Win32::Semaphore->new($initial,$maximum,$name);
$sem->wait;
DESCRIPTION
This module allows access to Win32 semaphore objects. The wait
method and wait_all
& wait_any
functions are inherited from the "Win32::IPC" module.
Methods
- $semaphore = Win32::Semaphore->new($initial, $maximum, [$name])
-
Constructor for a new semaphore object.
$initial
is the initial count, and$maximum
is the maximum count for the semaphore. If$name
is omitted, creates an unnamed semaphore object.If
$name
signifies an existing semaphore object, then$initial
and$maximum
are ignored and the object is opened. If this happens,$^E
will be set to 183 (ERROR_ALREADY_EXISTS). - $semaphore = Win32::Semaphore->open($name)
-
Constructor for opening an existing semaphore object.
- $semaphore->release([$increment, [$previous]])
-
Increment the count of
$semaphore
by$increment
(default 1). If$increment
plus the semaphore's current count is more than its maximum count, the count is not changed. Returns true if the increment is successful.The semaphore's count (before incrementing) is stored in the second argument (if any).
It is not necessary to wait on a semaphore before calling
release
, but you'd better know what you're doing. - $semaphore->wait([$timeout])
-
Wait for
$semaphore
's count to be nonzero, then decrement it by 1. See "Win32::IPC".
Deprecated Functions and Methods
Win32::Semaphore still supports the ActiveWare syntax, but its use is deprecated.
- Win32::Semaphore::Create($SemObject,$Initial,$Max,$Name)
-
Use
$SemObject = Win32::Semaphore->new($Initial,$Max,$Name)
instead. - Win32::Semaphore::Open($SemObject, $Name)
-
Use
$SemObject = Win32::Semaphore->open($Name)
instead. - $SemObj->Release($Count,$LastVal)
-
Use
$SemObj->release($Count,$LastVal)
instead.
AUTHOR
Christopher J. Madsen <cjm@pobox.com>
Loosely based on the original module by ActiveWare Internet Corp., http://www.ActiveWare.com