Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libqueue.tex @ 13163:a09e8635534d legacy-trunk
Don't try to guess the name of a .def file -- if one is supplied, use it,
otherwise just generate an '/export:' option.
| author | Greg Ward <gward@python.net> |
|---|---|
| date | Thu, 29 Jun 2000 23:09:20 +0000 |
| parents | e82e82b3b9ad |
| children | 563dee598d3a |
| rev | line source |
|---|---|
| 8918 | 1 \section{\module{Queue} --- |
| 2 A synchronized queue class.} | |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
3 \declaremodule{standard}{Queue} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
4 |
| 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 |
|
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
8 |
| 7634 | 9 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
|
10 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
|
11 information must be exchanged safely between multiple threads. The |
| 7634 | 12 \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
|
13 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
|
14 Python. |
|
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
15 |
| 7634 | 16 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
|
17 |
|
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
18 |
| 7634 | 19 \begin{classdesc}{Queue}{maxsize} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
20 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
|
21 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
|
22 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
|
23 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
|
24 zero, the queue size is infinite. |
| 7634 | 25 \end{classdesc} |
| 26 | |
| 27 \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
|
28 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
|
29 \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
|
30 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
|
31 \end{excdesc} |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
32 |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
33 \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
|
34 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
|
35 \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
|
36 full or locked. |
| 7634 | 37 \end{excdesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
38 |
| 7634 | 39 \subsection{Queue Objects} |
| 40 \label{QueueObjects} | |
| 41 | |
| 42 Class \class{Queue} implements queue objects and has the methods | |
| 43 described below. This class can be derived from in order to implement | |
| 44 other queue organizations (e.g. stack) but the inheritable interface | |
| 45 is not described here. See the source code for details. The public | |
| 46 methods are: | |
| 47 | |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
48 \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
|
49 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
|
50 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
|
51 \end{methoddesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
52 |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
53 \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
|
54 Return \code{1} if the queue is empty, \code{0} otherwise. Because |
| 7634 | 55 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
|
56 \end{methoddesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
57 |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
58 \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
|
59 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
|
60 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
|
61 \end{methoddesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
62 |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
63 \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
|
64 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
|
65 (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
|
66 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
|
67 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
|
68 exception. |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
69 \end{methoddesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
70 |
|
10121
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
71 \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
|
72 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
|
73 \end{methoddesc} |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
74 |
|
b7d8125c2417
Update documentation to reflect changes to Queue.py by Tim Peters.
Guido van Rossum <guido@python.org>
parents:
8918
diff
changeset
|
75 \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
|
76 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
|
77 \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
|
78 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
|
79 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
|
80 \exception{Empty} exception. |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
81 \end{methoddesc} |
|
6611
e6b9d21c8e0c
libqueue.tex: Documentation for the Queue.py module.
Barry Warsaw <barry@python.org>
parents:
diff
changeset
|
82 |
|
7768
8f177933c41f
Use the new {methoddesc} and {memberdesc} environments as appropriate.
Fred Drake <fdrake@acm.org>
parents:
7634
diff
changeset
|
83 \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
|
84 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
|
85 \end{methoddesc} |
