Note that two-phase cyclic barriers are suitable for use in loops.

This commit is contained in:
Raymond Hettinger 2011-01-17 21:05:07 +00:00
parent 37b9e46a04
commit 15b47c5d7f
1 changed files with 4 additions and 2 deletions

View File

@ -834,8 +834,10 @@ Barriers can work with an arbitrary number of threads. This is a generalization
of a `Rendezvous <http://en.wikipedia.org/wiki/Synchronous_rendezvous>`_ which of a `Rendezvous <http://en.wikipedia.org/wiki/Synchronous_rendezvous>`_ which
is defined for only two threads. is defined for only two threads.
The barrier is designed to be cyclic, making it reusable once all of the Implemented as a two-phase cyclic barrier, :class:`~threading.Barrier` objects
waiting threads are released. are suitable for use in loops. The separate *filling* and *draining* phases
assure that all threads get released (drained) before any one them can loop back
and re-enter the barrier. The barrier fully resets after each cycle.
If any of the predecessor tasks can hang or be delayed, a barrier can be created If any of the predecessor tasks can hang or be delayed, a barrier can be created
with an optional *timeout* parameter. Then if the timeout period elapses before with an optional *timeout* parameter. Then if the timeout period elapses before