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

« back to all changes in this revision

Viewing changes to Thread/Queue.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::Queue</div>
84
87
      <div id="contentBody"><div class="title_container"><div class="page_title">Thread::Queue</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><li><a href="#SEE-ALSO">SEE ALSO</a></ul><a name="NAME"></a><h1>NAME</h1>
85
88
<p>Thread::Queue - thread-safe queues</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/Queue.html">Thread::Queue</a><span class="sc">;</span>
88
 
    <a class="l_k" href="../functions/my.html">my</a> <span class="i">$q</span> = new <a class="l_w" href="../Thread/Queue.html">Thread::Queue</a><span class="sc">;</span>
 
90
<pre class="verbatim">    <a class="l_k" href="../functions/use.html">use</a> <span class="w">Thread::Queue</span><span class="sc">;</span>
 
91
    <a class="l_k" href="../functions/my.html">my</a> <span class="i">$q</span> = <span class="w">new</span> <span class="w">Thread::Queue</span><span class="sc">;</span>
89
92
    <span class="i">$q</span><span class="i">-&gt;enqueue</span><span class="s">(</span><span class="q">&quot;foo&quot;</span><span class="cm">,</span> <span class="q">&quot;bar&quot;</span><span class="s">)</span><span class="sc">;</span>
90
93
    <a class="l_k" href="../functions/my.html">my</a> <span class="i">$foo</span> = <span class="i">$q</span><span class="i">-&gt;dequeue</span><span class="sc">;</span>    <span class="c"># The &quot;bar&quot; is still in the queue.</span>
91
94
    <a class="l_k" href="../functions/my.html">my</a> <span class="i">$foo</span> = <span class="i">$q</span><span class="i">-&gt;dequeue_nb</span><span class="sc">;</span> <span class="c"># returns &quot;bar&quot;, or undef if the queue was empty</span>
92
95
    <a class="l_k" href="../functions/my.html">my</a> <span class="i">$left</span> = <span class="i">$q</span><span class="i">-&gt;pending</span><span class="sc">;</span>   <span class="c"># returns the number of items still in the queue</span></pre>
93
96
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
94
 
<p>A queue, as implemented by <code class="inline"><a class="l_w" href="../Thread/Queue.html">Thread::Queue</a></code> is a thread-safe 
 
97
<p>A queue, as implemented by <code class="inline"><span class="w">Thread::Queue</span></code>
 
98
 is a thread-safe 
95
99
data structure much like a list.  Any number of threads can safely 
96
100
add elements to the end of the list, or remove elements from the head 
97
101
of the list. (Queues don't permit adding or removing elements from 
99
103
<a name="FUNCTIONS-AND-METHODS"></a><h1>FUNCTIONS AND METHODS</h1>
100
104
<ul>
101
105
<li><a name="new"></a><b>new</b>
102
 
<p>The <code class="inline">new</code>
 
106
<p>The <code class="inline"><span class="w">new</span></code>
103
107
 function creates a new empty queue.</p>
104
108
</li>
105
109
<li><a name="enqueue-LIST"></a><b>enqueue LIST</b>
106
 
<p>The <code class="inline">enqueue</code>
 
110
<p>The <code class="inline"><span class="w">enqueue</span></code>
107
111
 method adds a list of scalars on to the end of the queue.
108
112
The queue will grow as needed to accommodate the list.</p>
109
113
</li>
110
114
<li><a name="dequeue"></a><b>dequeue</b>
111
 
<p>The <code class="inline">dequeue</code>
 
115
<p>The <code class="inline"><span class="w">dequeue</span></code>
112
116
 method removes a scalar from the head of the queue and
113
 
returns it. If the queue is currently empty, <code class="inline">dequeue</code>
 
117
returns it. If the queue is currently empty, <code class="inline"><span class="w">dequeue</span></code>
114
118
 will block the
115
 
thread until another thread <code class="inline">enqueue</code>
 
119
thread until another thread <code class="inline"><span class="w">enqueue</span></code>
116
120
s a scalar.</p>
117
121
</li>
118
122
<li><a name="dequeue_nb"></a><b>dequeue_nb</b>
119
 
<p>The <code class="inline">dequeue_nb</code>
120
 
 method, like the <code class="inline">dequeue</code>
 
123
<p>The <code class="inline"><span class="w">dequeue_nb</span></code>
 
124
 method, like the <code class="inline"><span class="w">dequeue</span></code>
121
125
 method, removes a scalar from
122
 
the head of the queue and returns it. Unlike <code class="inline">dequeue</code>
 
126
the head of the queue and returns it. Unlike <code class="inline"><span class="w">dequeue</span></code>
123
127
, though,
124
 
<code class="inline">dequeue_nb</code>
 
128
<code class="inline"><span class="w">dequeue_nb</span></code>
125
129
 won't block if the queue is empty, instead returning
126
130
<code class="inline"><a class="l_k" href="../functions/undef.html">undef</a></code>.</p>
127
131
</li>
128
132
<li><a name="pending"></a><b>pending</b>
129
 
<p>The <code class="inline">pending</code>
 
133
<p>The <code class="inline"><span class="w">pending</span></code>
130
134
 method returns the number of items still in the queue.</p>
131
135
</li>
132
136
</ul>
149
153
          <!--<select name="r"><option value="1" selected>Go to top result<option value="0">Show results list</select>-->
150
154
        </form>
151
155
      </p>
 
156
      <script language="JavaScript" type="text/javascript" src="/perl-version.js"></script>
152
157
      <h2>Labels:</h2>
153
158
      <p>
154
159
        <a href="#" onClick="addLabel('Thread::Queue','Thread/Queue.html')">Add this page</a>