| 1949 | # for the same purpose. |
| 1950 | |
| 1951 | class _DummyList(object): |
| 1952 | |
| 1953 | def __init__(self): |
| 1954 | wrapper = multiprocessing.heap.BufferWrapper(struct.calcsize('i')) |
| 1955 | lock = multiprocessing.Lock() |
| 1956 | self.__setstate__((wrapper, lock)) |
| 1957 | self._lengthbuf[0] = 0 |
| 1958 | |
| 1959 | def __setstate__(self, state): |
| 1960 | (self._wrapper, self._lock) = state |
| 1961 | self._lengthbuf = self._wrapper.create_memoryview().cast('i') |
| 1962 | |
| 1963 | def __getstate__(self): |
| 1964 | return (self._wrapper, self._lock) |
| 1965 | |
| 1966 | def append(self, _): |
| 1967 | with self._lock: |
| 1968 | self._lengthbuf[0] += 1 |
| 1969 | |
| 1970 | def __len__(self): |
| 1971 | with self._lock: |
| 1972 | return self._lengthbuf[0] |
| 1973 | |
| 1974 | def _wait(): |
| 1975 | # A crude wait/yield function not relying on synchronization primitives. |