Wait for the barrier. When the specified number of tasks have started waiting, they are all simultaneously awoken. Returns an unique and individual index number from 0 to 'parties-1'.
(self)
| 509 | pass |
| 510 | |
| 511 | async def wait(self): |
| 512 | """Wait for the barrier. |
| 513 | |
| 514 | When the specified number of tasks have started waiting, they are all |
| 515 | simultaneously awoken. |
| 516 | Returns an unique and individual index number from 0 to 'parties-1'. |
| 517 | """ |
| 518 | async with self._cond: |
| 519 | await self._block() # Block while the barrier drains or resets. |
| 520 | try: |
| 521 | index = self._count |
| 522 | self._count += 1 |
| 523 | if index + 1 == self._parties: |
| 524 | # We release the barrier |
| 525 | await self._release() |
| 526 | else: |
| 527 | await self._wait() |
| 528 | return index |
| 529 | finally: |
| 530 | self._count -= 1 |
| 531 | # Wake up any tasks waiting for barrier to drain. |
| 532 | self._exit() |
| 533 | |
| 534 | async def _block(self): |
| 535 | # Block until the barrier is ready for us, |