Create a barrier, initialised to 'parties' threads. 'action' is a callable which, when supplied, will be called by one of the threads after they have all entered the barrier and just prior to releasing them all. If a 'timeout' is provided, it is used as the default f
(self, parties, action=None, timeout=None)
| 685 | """ |
| 686 | |
| 687 | def __init__(self, parties, action=None, timeout=None): |
| 688 | """Create a barrier, initialised to 'parties' threads. |
| 689 | |
| 690 | 'action' is a callable which, when supplied, will be called by one of |
| 691 | the threads after they have all entered the barrier and just prior to |
| 692 | releasing them all. If a 'timeout' is provided, it is used as the |
| 693 | default for all subsequent 'wait()' calls. |
| 694 | |
| 695 | """ |
| 696 | if parties < 1: |
| 697 | raise ValueError("parties must be >= 1") |
| 698 | self._cond = Condition(Lock()) |
| 699 | self._action = action |
| 700 | self._timeout = timeout |
| 701 | self._parties = parties |
| 702 | self._state = 0 # 0 filling, 1 draining, -1 resetting, -2 broken |
| 703 | self._count = 0 |
| 704 | |
| 705 | def __repr__(self): |
| 706 | cls = self.__class__ |