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)
| 479 | pass |
| 480 | |
| 481 | async def wait(self): |
| 482 | """Wait for the barrier. |
| 483 | |
| 484 | When the specified number of tasks have started waiting, they are all |
| 485 | simultaneously awoken. |
| 486 | Returns an unique and individual index number from 0 to 'parties-1'. |
| 487 | """ |
| 488 | async with self._cond: |
| 489 | await self._block() # Block while the barrier drains or resets. |
| 490 | try: |
| 491 | index = self._count |
| 492 | self._count += 1 |
| 493 | if index + 1 == self._parties: |
| 494 | # We release the barrier |
| 495 | await self._release() |
| 496 | else: |
| 497 | await self._wait() |
| 498 | return index |
| 499 | finally: |
| 500 | self._count -= 1 |
| 501 | # Wake up any tasks waiting for barrier to drain. |
| 502 | self._exit() |
| 503 | |
| 504 | async def _block(self): |
| 505 | # Block until the barrier is ready for us, |
no test coverage detected