annotate Doc/lib/libqueue.tex @ 8831:00a6bb65ff29 legacy-trunk

Getting rid of this ancient stuff.
author Guido van Rossum <guido@python.org>
date Wed, 05 Aug 1998 21:10:09 +0000
parents 760dcf197048
children acfffe14628e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7877
8e5223680a9d Remove all uses of \sectcode; we can now use logical markup everywhere.
Fred Drake <fdrake@acm.org>
parents: 7768
diff changeset
1 \section{Standard Module \module{Queue}}
8716
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
2 \declaremodule{standard}{Queue}
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
3
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
4 \modulesynopsis{A stynchronized queue class.}
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
5
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
6
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
7
7634
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
8 The \module{Queue} module implements a multi-producer, multi-consumer
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
9 FIFO queue. It is especially useful in threads programming when
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
10 information must be exchanged safely between multiple threads. The
7634
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
11 \class{Queue} class in this module implements all the required locking
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
12 semantics. It depends on the availability of thread support in
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
13 Python.
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
14
7634
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
15 The \module{Queue} module defines the following class and exception:
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
16
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
17
7634
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
18 \begin{classdesc}{Queue}{maxsize}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
19 Constructor for the class. \var{maxsize} is an integer that sets the
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
20 upperbound limit on the number of items that can be placed in the
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
21 queue. Insertion will block once this size has been reached, until
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
22 queue items are consumed. If \var{maxsize} is less than or equal to
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
23 zero, the queue size is infinite.
7634
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
24 \end{classdesc}
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
25
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
26 \begin{excdesc}{Empty}
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
27 Exception raised when non-blocking get (e.g. \method{get_nowait()}) is
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
28 called on a \class{Queue} object which is empty, or for which the
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
29 emptyiness cannot be determined (i.e. because the appropriate locks
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
30 cannot be acquired).
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
31 \end{excdesc}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
32
7634
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
33 \subsection{Queue Objects}
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
34 \label{QueueObjects}
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
35
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
36 Class \class{Queue} implements queue objects and has the methods
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
37 described below. This class can be derived from in order to implement
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
38 other queue organizations (e.g. stack) but the inheritable interface
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
39 is not described here. See the source code for details. The public
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
40 methods are:
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
41
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
42 \begin{methoddesc}{qsize}{}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
43 Returns the approximate size of the queue. Because of multithreading
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
44 semantics, this number is not reliable.
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
45 \end{methoddesc}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
46
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
47 \begin{methoddesc}{empty}{}
7634
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
48 Returns \code{1} if the queue is empty, \code{0} otherwise. Because
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
49 of multithreading semantics, this is not reliable.
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
50 \end{methoddesc}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
51
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
52 \begin{methoddesc}{full}{}
7634
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
53 Returns \code{1} if the queue is full, \code{0} otherwise. Because of
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
54 multithreading semantics, this is not reliable.
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
55 \end{methoddesc}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
56
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
57 \begin{methoddesc}{put}{item}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
58 Puts \var{item} into the queue.
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
59 \end{methoddesc}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
60
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
61 \begin{methoddesc}{get}{}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
62 Gets and returns an item from the queue, blocking if necessary until
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
63 one is available.
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
64 \end{methoddesc}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
65
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
66 \begin{methoddesc}{get_nowait}{}
6611
e6b9d21c8e0c libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff changeset
67 Gets and returns an item from the queue if one is immediately
7634
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
68 available. Raises an \exception{Empty} exception if the queue is
3d1590b5e3dd Logical markup.
Fred Drake <fdrake@acm.org>
parents: 7277
diff changeset
69 empty or if the queue's emptiness cannot be determined.
7768
8f177933c41f Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents: 7634
diff changeset
70 \end{methoddesc}