Automatically syncronizes threads.
(self)
| 22 | self.__exit.acquire() |
| 23 | |
| 24 | def sync(self): |
| 25 | 'Automatically syncronizes threads.' |
| 26 | self.__main.acquire() |
| 27 | self.__count += 1 |
| 28 | if self.__count < self.__threads: |
| 29 | self.__main.release() |
| 30 | else: |
| 31 | self.__exit.release() |
| 32 | self.__exit.acquire() |
| 33 | self.__count -= 1 |
| 34 | if self.__count > 0: |
| 35 | self.__exit.release() |
| 36 | else: |
| 37 | self.__main.release() |
| 38 | |
| 39 | ################################################################################ |
| 40 |