Threading question
Aahz
aahz at pythoncraft.com
Wed Jun 19 21:24:14 EDT 2002
In article <mailman.1024533445.11872.python-list at python.org>,
Trent Mick <trentm at ActiveState.com> wrote:
>[David LeBlanc wrote]
>>
>> with a thread sitting in a loop processing intermittant transactions from a
>> buffer, how does one wait if reading an empty buffer does not block - how do
>> you relinquish control to other threads/processes?
>
>There are probably a bunch of ways to do it but here is one.
>
>If you have access to the code that populates the buffer then given
>everyone a handle to a condition variable and have the reader .wait() on
>that condition and have anyone who adds data to the buffer .notify() or
>.notifyAll() on that condition.
If you're doing that, just have the code populating the buffer change
the buffer to a Queue. Much simpler.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Project Vote Smart: http://www.vote-smart.org/
More information about the Python-list
mailing list