MCPcopy Index your code
hub / github.com/python/cpython / Barrier

Class Barrier

Lib/multiprocessing/synchronize.py:377–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375#
376
377class Barrier(threading.Barrier):
378
379 def __init__(self, parties, action=None, timeout=None, *, ctx):
380 import struct
381 from .heap import BufferWrapper
382 wrapper = BufferWrapper(struct.calcsize('i') * 2)
383 cond = ctx.Condition()
384 self.__setstate__((parties, action, timeout, cond, wrapper))
385 self._state = 0
386 self._count = 0
387
388 def __setstate__(self, state):
389 (self._parties, self._action, self._timeout,
390 self._cond, self._wrapper) = state
391 self._array = self._wrapper.create_memoryview().cast('i')
392
393 def __getstate__(self):
394 return (self._parties, self._action, self._timeout,
395 self._cond, self._wrapper)
396
397 @property
398 def _state(self):
399 return self._array[0]
400
401 @_state.setter
402 def _state(self, value):
403 self._array[0] = value
404
405 @property
406 def _count(self):
407 return self._array[1]
408
409 @_count.setter
410 def _count(self, value):
411 self._array[1] = value

Callers 1

BarrierMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…