| 120 | self._print_mutex = threading.Lock() |
| 121 | |
| 122 | def process(self, items): |
| 123 | self._pending = list(items) |
| 124 | self._thread_count = 0 |
| 125 | self._has_errors = False |
| 126 | self._process_done.clear() |
| 127 | |
| 128 | while self._pending: |
| 129 | item = self._next() |
| 130 | if item: |
| 131 | with self._mutex: |
| 132 | self._thread_count += item.permutations |
| 133 | threading.Thread(target=self._worker, args=(item,)).start() |
| 134 | else: |
| 135 | self._process_done.wait() |
| 136 | self._process_done.clear() |
| 137 | |
| 138 | logging.debug('Waiting for the last shaders to compile') |
| 139 | while True: |
| 140 | with self._mutex: |
| 141 | if self._thread_count <= 0: |
| 142 | break |
| 143 | self._process_done.wait() |
| 144 | self._process_done.clear() |
| 145 | |
| 146 | logging.debug('Done building all files') |
| 147 | return not self._has_errors |
| 148 | |
| 149 | def _next(self): |
| 150 | for i in range(len(self._pending)): |