[Python-checkins] python/dist/src/Doc/lib libqueue.tex,1.14,1.15

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Mon Jul 12 02:45:16 CEST 2004


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32296/Doc/lib
Modified Files:
	libqueue.tex 
Log Message:
Bug #788520: Queue class has logic error when non-blocking
I don't agree it had a bug (see the report), so this is *not* a candidate
for backporting, but the docs were confusing and the Queue implementation
was old enough to vote.
Rewrote put/put_nowait/get/get_nowait from scratch, to use a pair of
Conditions (not_full and not_empty), sharing a common mutex. The code
is 1/4 the size now, and 6.25x easier to understand. For blocking
with timeout, we also get to reuse (indirectly) the tedious timeout
code from threading.Condition. The Full and Empty exceptions raised
by non-blocking calls are now easy (instead of nearly impossible) to
explain truthfully: Full is raised if and only if the Queue truly
is full when the non-blocking put call checks the queue size, and
similarly for Empty versus non-blocking get.
What I don't know is whether the new implementation is slower (or
faster) than the old one. I don't really care. Anyone who cares
a lot is encouraged to check that.
Index: libqueue.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libqueue.tex,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** libqueue.tex	29 Jan 2004 06:37:48 -0000	1.14
--- libqueue.tex	12 Jul 2004 00:45:14 -0000	1.15
***************
*** 27,31 ****
 Exception raised when non-blocking \method{get()} (or
 \method{get_nowait()}) is called on a \class{Queue} object which is
! empty or locked.
 \end{excdesc}
 
--- 27,31 ----
 Exception raised when non-blocking \method{get()} (or
 \method{get_nowait()}) is called on a \class{Queue} object which is
! empty.
 \end{excdesc}
 
***************
*** 33,37 ****
 Exception raised when non-blocking \method{put()} (or
 \method{put_nowait()}) is called on a \class{Queue} object which is
! full or locked.
 \end{excdesc}
 
--- 33,37 ----
 Exception raised when non-blocking \method{put()} (or
 \method{put_nowait()}) is called on a \class{Queue} object which is
! full.
 \end{excdesc}
 
***************
*** 52,56 ****
 \begin{methoddesc}{empty}{}
 Return \code{True} if the queue is empty, \code{False} otherwise.
! Becauseof multithreading semantics, this is not reliable.
 \end{methoddesc}
 
--- 52,56 ----
 \begin{methoddesc}{empty}{}
 Return \code{True} if the queue is empty, \code{False} otherwise.
! Because of multithreading semantics, this is not reliable.
 \end{methoddesc}
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /