[ZODB-Dev] RE: [Zope] Re: Squid headaches

Tim Peters tim@zope.com
Sun, 1 Jun 2003 22:41:31 -0400

[Dieter Maurer]
> In other (i.e. non-Zope) code, I saw code like:
> 	 lock.release()
> 	 sleep(0) # indicate, threads should switch, if necessary
> 	 lock.acquire()
> Of course, "sleep(0)" may not force a thread switch on all platforms.

sleep(0) definitely forces a thread to yield its timeslice on Windows,
definitely does not on Solaris, and "beats me" for everything else.  Windows
is happy to switch threads frequently without this kind of trickery, though.

> My lock time optimization holds the lock only while it decides
> whether it has finished. It looks like:
> ...

Sorry, I don't know the packing code well enough to comment.