Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libqueue.tex @ 17581:c1937faabb23 2.1
Added support for optional explanation parameter to the \versionadded
macro.
Refactored do_cmd_versionadded() and do_cmd_versionchanged() to do most
of the work in a helper function, with the do_cmd_*() wrappers just supplying
a portion of the replacement text.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Wed, 18 Apr 2001 17:29:14 +0000 |
| parents | 563dee598d3a |
| children | 1f6510051c8a |
| rev | line source |
|---|---|
| 8918 | 1 \section{\module{Queue} --- |
|
15142
563dee598d3a
Fixed lots of small nits caught by Ka-Ping Yee <ping@lfw.org>.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
2 A synchronized queue class} |
|
563dee598d3a
Fixed lots of small nits caught by Ka-Ping Yee <ping@lfw.org>.
Fred Drake <fdrake@acm.org>
parents:
12223
diff
changeset
|
3 |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
4 \declaremodule{standard}{Queue} |
| 8918 | 5 \modulesynopsis{A synchronized queue class.} |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
6 |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
7 |
| 7634 | 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 | 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 | 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 | 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 | 24 \end{classdesc} |
| 25 | |
| 26 \begin{excdesc}{Empty} | |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
27 Exception raised when non-blocking \method{get()} (or |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
28 \method{get_nowait()}) is called on a \class{Queue} object which is |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
29 empty or locked. |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
30 \end{excdesc} |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
31 |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
32 \begin{excdesc}{Full} |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
33 Exception raised when non-blocking \method{put()} (or |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10121
diff
changeset
|
34 \method{put_nowait()}) is called on a \class{Queue} object which is |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
35 full or locked. |
| 7634 | 36 \end{excdesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
37 |
| 7634 | 38 \subsection{Queue Objects} |
| 39 \label{QueueObjects} | |
| 40 | |
| 41 Class \class{Queue} implements queue objects and has the methods | |
| 42 described below. This class can be derived from in order to implement | |
| 43 other queue organizations (e.g. stack) but the inheritable interface | |
| 44 is not described here. See the source code for details. The public | |
| 45 methods are: | |
| 46 | |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
47 \begin{methoddesc}{qsize}{} |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
48 Return the approximate size of the queue. Because of multithreading |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
49 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
|
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}{empty}{} |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
53 Return \code{1} if the queue is empty, \code{0} otherwise. Because |
| 7634 | 54 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
|
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}{full}{} |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
58 Return \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
|
59 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
|
60 \end{methoddesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
61 |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
62 \begin{methoddesc}{put}{item\optional{, block}} |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
63 Put \var{item} into the queue. If optional argument \var{block} is 1 |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
64 (the default), block if necessary until a free slot is available. |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
65 Otherwise (\var{block} is 0), put \var{item} on the queue if a free |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
66 slot is immediately available, else raise the \exception{Full} |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
67 exception. |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
68 \end{methoddesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
69 |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
70 \begin{methoddesc}{put_nowait}{item} |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
71 Equivalent to \code{put(\var{item}, 0)}. |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
72 \end{methoddesc} |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
73 |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
74 \begin{methoddesc}{get}{\optional{block}} |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
75 Remove and return an item from the queue. If optional argument |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
76 \var{block} is 1 (the default), block if necessary until an item is |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
77 available. Otherwise (\var{block} is 0), return an item if one is |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
78 immediately available, else raise the |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
79 \exception{Empty} exception. |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
80 \end{methoddesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
81 |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
82 \begin{methoddesc}{get_nowait}{} |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
83 Equivalent to \code{get(0)}. |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
84 \end{methoddesc} |
