Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / Thread / Queue.html
blobf509c75931764accff7007bdb86ecce3bc27fd19
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>Thread::Queue - thread-safe queues</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;Thread::Queue - thread-safe queues</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <li><a href="#functions_and_methods">FUNCTIONS AND METHODS</a></li>
26 <li><a href="#see_also">SEE ALSO</a></li>
27 </ul>
28 <!-- INDEX END -->
30 <hr />
31 <p>
32 </p>
33 <h1><a name="name">NAME</a></h1>
34 <p>Thread::Queue - thread-safe queues</p>
35 <p>
36 </p>
37 <hr />
38 <h1><a name="synopsis">SYNOPSIS</a></h1>
39 <pre>
40 use Thread::Queue;
41 my $q = new Thread::Queue;
42 $q-&gt;enqueue(&quot;foo&quot;, &quot;bar&quot;);
43 my $foo = $q-&gt;dequeue; # The &quot;bar&quot; is still in the queue.
44 my $foo = $q-&gt;dequeue_nb; # returns &quot;bar&quot;, or undef if the queue was empty
45 my $left = $q-&gt;pending; # returns the number of items still in the queue</pre>
46 <p>
47 </p>
48 <hr />
49 <h1><a name="description">DESCRIPTION</a></h1>
50 <p>A queue, as implemented by <code>Thread::Queue</code> is a thread-safe
51 data structure much like a list. Any number of threads can safely
52 add elements to the end of the list, or remove elements from the head
53 of the list. (Queues don't permit adding or removing elements from
54 the middle of the list).</p>
55 <p>
56 </p>
57 <hr />
58 <h1><a name="functions_and_methods">FUNCTIONS AND METHODS</a></h1>
59 <dl>
60 <dt><strong><a name="item_new">new</a></strong>
62 <dd>
63 <p>The <a href="#item_new"><code>new</code></a> function creates a new empty queue.</p>
64 </dd>
65 </li>
66 <dt><strong><a name="item_enqueue">enqueue LIST</a></strong>
68 <dd>
69 <p>The <a href="#item_enqueue"><code>enqueue</code></a> method adds a list of scalars on to the end of the queue.
70 The queue will grow as needed to accommodate the list.</p>
71 </dd>
72 </li>
73 <dt><strong><a name="item_dequeue">dequeue</a></strong>
75 <dd>
76 <p>The <a href="#item_dequeue"><code>dequeue</code></a> method removes a scalar from the head of the queue and
77 returns it. If the queue is currently empty, <a href="#item_dequeue"><code>dequeue</code></a> will block the
78 thread until another thread <a href="#item_enqueue"><code>enqueue</code></a>s a scalar.</p>
79 </dd>
80 </li>
81 <dt><strong><a name="item_dequeue_nb">dequeue_nb</a></strong>
83 <dd>
84 <p>The <a href="#item_dequeue_nb"><code>dequeue_nb</code></a> method, like the <a href="#item_dequeue"><code>dequeue</code></a> method, removes a scalar from
85 the head of the queue and returns it. Unlike <a href="#item_dequeue"><code>dequeue</code></a>, though,
86 <a href="#item_dequeue_nb"><code>dequeue_nb</code></a> won't block if the queue is empty, instead returning
87 <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_undef"><code>undef</code></a>.</p>
88 </dd>
89 </li>
90 <dt><strong><a name="item_pending">pending</a></strong>
92 <dd>
93 <p>The <a href="#item_pending"><code>pending</code></a> method returns the number of items still in the queue.</p>
94 </dd>
95 </li>
96 </dl>
97 <p>
98 </p>
99 <hr />
100 <h1><a name="see_also">SEE ALSO</a></h1>
101 <p><a href="file://C|\msysgit\mingw\html/lib/threads.html">the threads manpage</a>, <a href="file://C|\msysgit\mingw\html/lib/threads/shared.html">the threads::shared manpage</a></p>
102 <table border="0" width="100%" cellspacing="0" cellpadding="3">
103 <tr><td class="block" style="background-color: #cccccc" valign="middle">
104 <big><strong><span class="block">&nbsp;Thread::Queue - thread-safe queues</span></strong></big>
105 </td></tr>
106 </table>
108 </body>
110 </html>