NAME
Thread::Barrier - thread execution barrier
SYNOPSIS
use Thread::Barrier;
my $b = new Thread::Barrier;
$b->init($thr_cnt);
$b->wait;
ABSTRACT
Execution barrier for multiple threads.
DESCRIPTION
Thread barriers provide a mechanism for synchronization of multiple threads. All threads issuing a wait
on the barrier will block until the count of waiting threads meets some threshold value. This mechanism proves quite useful in situations where processing progresses in stages and completion of the current stage by all threads is the entry criteria for the next stage.
METHODS
- new
- new COUNT
-
new
creates a new barrier and initializes the threshold count toNUMBER
. IfNUMBER
is not specified, the threshold is set to 0. - init COUNT
-
init
specifies the threshold count for the barrier, must be zero or a positive integer. If the value ofCOUNT
is less than or equal to the number of threads blocking on the barrier wheninit
is called, the barrier is released and reset. - wait
-
wait
causes the thread to block until the number of threads blocking on the barrier meets the threshold. When the blocked threads are released, the barrier is reset to its initial state. - threshold
-
Returns the currently configured threshold.
- count
-
Returns the instantaneous count of threads blocking on the barrier.
WARNING: This is an accessor method that is intended for debugging purposes only, the lock on the barrier object is released when the method returns.
SEE ALSO
AUTHOR
Mark Rogaski, <mrogaski@cpan.org>
If you find this module useful or have any questions, comments, or suggestions please send me an email message.
COPYRIGHT AND LICENSE
Copyright 2002-2003, 2005 by Mark Rogaski.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the README file distributed with Perl for further details.