™.. Thread::Semaphore - Online Linux Manual PageSection : 3pm
Updated : 2009-02-12
Source : perl v5.10.1
Note : Perl Programmers Reference Guide

NAMEThread::Semaphore − Thread−safe semaphores

VERSIONThis document describes Thread::Semaphore version 2.09

SYNOPSIS​ use Thread::Semaphore; ​ my $s = Thread::Semaphore−>new(); ​ $s−>down(); # Also known as the semaphore P operation. ​ # The guarded section is here ​ $s−>up(); # Also known as the semaphore V operation. ​ ​ # The default semaphore value is 1 ​ my $s = Thread::Semaphore−new($initial_value); ​ $s−>down($down_value); ​ $s−>up($up_value);

DESCRIPTIONSemaphores provide a mechanism to regulate access to resources. Unlike locks, semaphores aren't tied to particular scalars, and so may be used to control access to anything you care to use them for. Semaphores don't limit their values to zero and one, so they can be used to control access to some resource that there may be more than one of (e.g., filehandles). Increment and decrement amounts aren't fixed at one either, so threads can reserve or return multiple resources at once.

METHODS>new() >new(NUMBER) \*(C`new\*(C'\fR creates a new semaphore, and initializes its count to the specified number (which must be an integer). If no number is specified, the semaphore's count defaults to 1. >down() >down(NUMBER) The \*(C`down\*(C'\fR method decreases the semaphore's count by the specified number (which must be an integer >= 1), or by one if no number is specified. If the semaphore's count would drop below zero, this method will block until such time as the semaphore's count is greater than or equal to the amount you're \*(C`down\*(C'\fRing the semaphore's count by. This is the semaphore P operation (the name derives from the Dutch word pak, which means capture \*(-- the semaphore operations were named by the late Dijkstra, who was Dutch). >up() >up(NUMBER) The \*(C`up\*(C'\fR method increases the semaphore's count by the number specified (which must be an integer >= 1), or by one if no number is specified. This will unblock any thread that is blocked trying to \*(C`down\*(C'\fR the semaphore if the \*(C`up\*(C'\fR raises the semaphore's count above the amount that the \*(C`down\*(C'\fR is trying to decrement it by. For example, if three threads are blocked trying to \*(C`down\*(C'\fR a semaphore by one, and another thread \f(CW\*(C`up\*(C'\fRs the semaphore by two, then two of the blocked threads (which two is indeterminate) will become unblocked. This is the semaphore V operation (the name derives from the Dutch word vrij, which means release).

NOTESSemaphores created by Thread::Semaphore can be used in both threaded and non-threaded applications. This allows you to write modules and packages that potentially make use of semaphores, and that will function in either environment.

SEE ALSOThread::Semaphore Discussion Forum on CPAN: <http://www.cpanforum.com/dist/Thread−Semaphore> Annotated POD for Thread::Semaphore: <http://annocpan.org/~JDHEDDEN/Thread−Semaphore−2.09/lib/Thread/Semaphore.pm> Source repository: <http://code.google.com/p/thread−semaphore/> threads, threads::shared

MAINTAINERJerry D. Hedden, <jdhedden AT cpan DOT org>

LICENSEThis program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
0
Johanes Gumabo
Data Size   :   11,687 byte
man-Thread::Semaphore.3pmBuild   :   2024-12-29, 07:25   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 259,086
Visitor ID   :     :  
Visitor IP   :   3.12.71.166   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.29
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|252|Thread::Semaphore.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|Thread::Semaphore.3pm|36/37|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|252|Thread::Semaphore.3pm|41|br══─}─══|'br══─}─══ )         (htmlprn|149|Thread::Semaphore.3pm|41|'br══─}─══ |'br══─}─══ )         (rof_nr_x|149|Thread::Semaphore.3pm|51/52|\nF|.ie \nF ══─{─══. de IX )         (rof_unit_scale_px|41|Thread::Semaphore.3pm|51/52|F|.ie \nF ══─{─══. de IX )         (rof_if|19|Thread::Semaphore.3pm|51/52|\nF|.ie \nF ══─{─══. de IX )         (htmlprn|149|Thread::Semaphore.3pm|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX )         (rof_escape_sequence|91|Thread::Semaphore.3pm|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2" )         (parse_manual_page_|252|Thread::Semaphore.3pm|57|══─}─══|.══─}─══ )         (htmlprn|149|Thread::Semaphore.3pm|57|.══─}─══ |.══─}─══ )         (rof_escape_sequence|91|Thread::Semaphore.3pm|169|\*(C`new\*(C'\fR creates a new semaphore, and initializes its count to the specified |\&\f(CW\*(C`new\*(C'\fR creates a new semaphore, and initializes its count to the specified )         (rof_escape_sequence|91|Thread::Semaphore.3pm|178|\*(C`down\*(C'\fR method decreases the semaphore's count by the specified number |The \f(CW\*(C`down\*(C'\fR method decreases the semaphore's count by the specified number )         (rof_escape_sequence|91|Thread::Semaphore.3pm|183|\*(C`down\*(C'\fRing the semaphore's count by. |amount you're \f(CW\*(C`down\*(C'\fRing the semaphore's count by. )         (rof_escape_sequence|91|Thread::Semaphore.3pm|186|\*(-- the semaphore operations were |word \*(L"pak\*(R", which means \*(L"capture\*(R" \*(-- the semaphore operations were )         (rof_escape_sequence|91|Thread::Semaphore.3pm|194|\*(C`up\*(C'\fR method increases the semaphore's count by the number specified |The \f(CW\*(C`up\*(C'\fR method increases the semaphore's count by the number specified )         (rof_escape_sequence|91|Thread::Semaphore.3pm|197|\*(C`down\*(C'\fR the |This will unblock any thread that is blocked trying to \f(CW\*(C`down\*(C'\fR the )         (rof_escape_sequence|91|Thread::Semaphore.3pm|198|\*(C`up\*(C'\fR raises the semaphore's count above the amount that |semaphore if the \f(CW\*(C`up\*(C'\fR raises the semaphore's count above the amount that )         (rof_escape_sequence|91|Thread::Semaphore.3pm|199|\*(C`down\*(C'\fR is trying to decrement it by. For example, if three threads |the \f(CW\*(C`down\*(C'\fR is trying to decrement it by. For example, if three threads )         (rof_escape_sequence|91|Thread::Semaphore.3pm|200|\*(C`down\*(C'\fR a semaphore by one, and another thread \f(CW\*(C`up\*(C'\fRs |are blocked trying to \f(CW\*(C`down\*(C'\fR a semaphore by one, and another thread \f(CW\*(C`up\*(C'\fRs )