~ubuntu-branches/ubuntu/intrepid/perl-doc-html/intrepid

« back to all changes in this revision

Viewing changes to Thread/Semaphore.html

  • Committer: Bazaar Package Importer
  • Author(s): Roberto C. Sanchez
  • Date: 2008-05-17 20:14:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080517201419-qgbuogq2ckkdisyi
Tags: 5.10.0-2
Supersede botched upload of 5.10.0-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
      <h2>Links:</h2>
55
55
      <ul>
56
56
        <li><a href="http://search.cpan.org">CPAN</a></li>
 
57
        <li><a href="http://www.perl.org">Perl.org</a></li>
57
58
        <li><a href="http://www.perl.com">Perl.com</a></li>
58
 
        <li><a href="http://www.perl.org">Perl.org</a></li>
 
59
        <li><a href="http://perlbuzz.com">Perl Buzz</a></li>
 
60
        <li><a href="http://www.perlfoundation.org/perl5/index.cgi">Perl 5 Wiki</a></li>
 
61
        <li><a href="http://jobs.perl.org">Perl Jobs</a></li>
59
62
        <li><a href="http://www.pm.org">Perl Mongers</a></li>
60
63
        <li><a href="http://www.perlmonks.org">Perl Monks</a></li>
61
64
        <li><a href="http://planet.perl.org">Planet Perl</a></li>
65
68
      <ul>
66
69
        <li>Site maintained by<br><a href="http://perl.jonallen.info">Jon Allen</a>
67
70
            (<a href="http://perl.jonallen.info">JJ</a>)</li>
68
 
        <li class="spaced">Last updated on<br>23 April 2006</li>
 
71
        <li class="spaced">Last updated on<br>23 December 2007</li>
69
72
        <li class="spaced">See the <a href="http://perl.jonallen.info/projects/perldoc">project page</a> for
70
73
        more details</li>
71
74
      </ul>
76
79
    <div id="centerContent">
77
80
      <div id="contentHeader">
78
81
        <div id="contentHeaderLeft"><a href="#" onClick="showLeft()">Show navigation</a></div>
79
 
        <div id="contentHeaderCentre">-- Perl 5.8.8 documentation --</div>
 
82
        <div id="contentHeaderCentre">-- Perl 5.10.0 documentation --</div>
80
83
        <div id="contentHeaderRight"><a href="#" onClick="showRight()">Show toolbar</a></div>
81
84
      </div>
82
85
      <div id="breadCrumbs"><a href="../index.html">Home</a> &gt; <a href="../index-modules-A.html">Core modules</a> &gt; <a href="../index-modules-T.html">T</a> &gt; Thread::Semaphore</div>
84
87
      <div id="contentBody"><div class="title_container"><div class="page_title">Thread::Semaphore</div></div><ul><li><a href="#NAME">NAME</a><li><a href="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#FUNCTIONS-AND-METHODS">FUNCTIONS AND METHODS</a></ul><a name="NAME"></a><h1>NAME</h1>
85
88
<p>Thread::Semaphore - thread-safe semaphores</p>
86
89
<a name="SYNOPSIS"></a><h1>SYNOPSIS</h1>
87
 
<pre class="verbatim">    <a class="l_k" href="../functions/use.html">use</a> <a class="l_w" href="../Thread/Semaphore.html">Thread::Semaphore</a><span class="sc">;</span>
88
 
    <a class="l_k" href="../functions/my.html">my</a> <span class="i">$s</span> = new <a class="l_w" href="../Thread/Semaphore.html">Thread::Semaphore</a><span class="sc">;</span>
 
90
<pre class="verbatim">    <a class="l_k" href="../functions/use.html">use</a> <span class="w">Thread::Semaphore</span><span class="sc">;</span>
 
91
    <a class="l_k" href="../functions/my.html">my</a> <span class="i">$s</span> = <span class="w">new</span> <span class="w">Thread::Semaphore</span><span class="sc">;</span>
89
92
    <span class="i">$s</span><span class="i">-&gt;down</span><span class="sc">;</span>  <span class="c"># Also known as the semaphore P operation.</span>
90
93
    <span class="c"># The guarded section is here</span>
91
94
    <span class="i">$s</span><span class="i">-&gt;up</span><span class="sc">;</span>    <span class="c"># Also known as the semaphore V operation.</span></pre>
92
95
<pre class="verbatim">    <span class="c"># The default semaphore value is 1.</span>
93
 
    <a class="l_k" href="../functions/my.html">my</a> <span class="i">$s</span> = new <span class="i">Thread::Semaphore</span><span class="s">(</span><span class="i">$initial_value</span><span class="s">)</span><span class="sc">;</span>
 
96
    <a class="l_k" href="../functions/my.html">my</a> <span class="i">$s</span> = <span class="w">new</span> <span class="i">Thread::Semaphore</span><span class="s">(</span><span class="i">$initial_value</span><span class="s">)</span><span class="sc">;</span>
94
97
    <span class="i">$s</span><span class="i">-&gt;down</span><span class="s">(</span><span class="i">$down_value</span><span class="s">)</span><span class="sc">;</span>
95
98
    <span class="i">$s</span><span class="i">-&gt;up</span><span class="s">(</span><span class="i">$up_value</span><span class="s">)</span><span class="sc">;</span></pre>
96
99
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
106
109
<li><a name="new"></a><b>new</b>
107
110
</li>
108
111
<li><a name="new-NUMBER"></a><b>new NUMBER</b>
109
 
<p><code class="inline">new</code>
 
112
<p><code class="inline"><span class="w">new</span></code>
110
113
 creates a new semaphore, and initializes its count to the passed
111
114
number. If no number is passed, the semaphore's count is set to one.</p>
112
115
</li>
113
116
<li><a name="down"></a><b>down</b>
114
117
</li>
115
118
<li><a name="down-NUMBER"></a><b>down NUMBER</b>
116
 
<p>The <code class="inline">down</code>
 
119
<p>The <code class="inline"><span class="w">down</span></code>
117
120
 method decreases the semaphore's count by the specified number,
118
121
or by one if no number has been specified. If the semaphore's count would drop
119
122
below zero, this method will block until such time that the semaphore's
120
 
count is equal to or larger than the amount you're <code class="inline">down</code>
 
123
count is equal to or larger than the amount you're <code class="inline"><span class="w">down</span></code>
121
124
ing the
122
125
semaphore's count by.</p>
123
126
<p>This is the semaphore "P operation" (the name derives from the Dutch
127
130
<li><a name="up"></a><b>up</b>
128
131
</li>
129
132
<li><a name="up-NUMBER"></a><b>up NUMBER</b>
130
 
<p>The <code class="inline">up</code>
 
133
<p>The <code class="inline"><span class="w">up</span></code>
131
134
 method increases the semaphore's count by the number specified,
132
135
or by one if no number has been specified. This will unblock any thread blocked
133
 
trying to <code class="inline">down</code>
134
 
 the semaphore if the <code class="inline">up</code>
 
136
trying to <code class="inline"><span class="w">down</span></code>
 
137
 the semaphore if the <code class="inline"><span class="w">up</span></code>
135
138
 raises the semaphore count
136
 
above the amount that the <code class="inline">down</code>
 
139
above the amount that the <code class="inline"><span class="w">down</span></code>
137
140
s are trying to decrement it by.</p>
138
141
<p>This is the semaphore "V operation" (the name derives from the Dutch
139
142
word "vrij", which means "release").</p>
156
159
          <!--<select name="r"><option value="1" selected>Go to top result<option value="0">Show results list</select>-->
157
160
        </form>
158
161
      </p>
 
162
      <script language="JavaScript" type="text/javascript" src="/perl-version.js"></script>
159
163
      <h2>Labels:</h2>
160
164
      <p>
161
165
        <a href="#" onClick="addLabel('Thread::Semaphore','Thread/Semaphore.html')">Add this page</a>