1 \section{Standard Module
\module{Queue
}}
6 The
\module{Queue
} module implements a multi-producer, multi-consumer
7 FIFO queue. It is especially useful in threads programming when
8 information must be exchanged safely between multiple threads. The
9 \class{Queue
} class in this module implements all the required locking
10 semantics. It depends on the availability of thread support in
13 The
\module{Queue
} module defines the following class and exception:
16 \begin{classdesc
}{Queue
}{maxsize
}
17 Constructor for the class.
\var{maxsize
} is an integer that sets the
18 upperbound limit on the number of items that can be placed in the
19 queue. Insertion will block once this size has been reached, until
20 queue items are consumed. If
\var{maxsize
} is less than or equal to
21 zero, the queue size is infinite.
24 \begin{excdesc
}{Empty
}
25 Exception raised when non-blocking get (e.g.
\method{get_nowait()
}) is
26 called on a
\class{Queue
} object which is empty, or for which the
27 emptyiness cannot be determined (i.e. because the appropriate locks
31 \subsection{Queue Objects
}
34 Class
\class{Queue
} implements queue objects and has the methods
35 described below. This class can be derived from in order to implement
36 other queue organizations (e.g. stack) but the inheritable interface
37 is not described here. See the source code for details. The public
40 \begin{methoddesc
}{qsize
}{}
41 Returns the approximate size of the queue. Because of multithreading
42 semantics, this number is not reliable.
45 \begin{methoddesc
}{empty
}{}
46 Returns
\code{1} if the queue is empty,
\code{0} otherwise. Because
47 of multithreading semantics, this is not reliable.
50 \begin{methoddesc
}{full
}{}
51 Returns
\code{1} if the queue is full,
\code{0} otherwise. Because of
52 multithreading semantics, this is not reliable.
55 \begin{methoddesc
}{put
}{item
}
56 Puts
\var{item
} into the queue.
59 \begin{methoddesc
}{get
}{}
60 Gets and returns an item from the queue, blocking if necessary until
64 \begin{methoddesc
}{get_nowait
}{}
65 Gets and returns an item from the queue if one is immediately
66 available. Raises an
\exception{Empty
} exception if the queue is
67 empty or if the queue's emptiness cannot be determined.