| 2153 | # for the same purpose. |
| 2154 | |
| 2155 | class _DummyList(object): |
| 2156 | |
| 2157 | def __init__(self): |
| 2158 | wrapper = multiprocessing.heap.BufferWrapper(struct.calcsize('i')) |
| 2159 | lock = multiprocessing.Lock() |
| 2160 | self.__setstate__((wrapper, lock)) |
| 2161 | self._lengthbuf[0] = 0 |
| 2162 | |
| 2163 | def __setstate__(self, state): |
| 2164 | (self._wrapper, self._lock) = state |
| 2165 | self._lengthbuf = self._wrapper.create_memoryview().cast('i') |
| 2166 | |
| 2167 | def __getstate__(self): |
| 2168 | return (self._wrapper, self._lock) |
| 2169 | |
| 2170 | def append(self, _): |
| 2171 | with self._lock: |
| 2172 | self._lengthbuf[0] += 1 |
| 2173 | |
| 2174 | def __len__(self): |
| 2175 | with self._lock: |
| 2176 | return self._lengthbuf[0] |
| 2177 | |
| 2178 | def _wait(): |
| 2179 | # A crude wait/yield function not relying on synchronization primitives. |