_sync.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:trio 作者: python-trio 项目源码 文件源码
def __init__(self, capacity):
        if not isinstance(capacity, int):
            raise TypeError("capacity must be an integer")
        if capacity < 1:
            raise ValueError("capacity must be >= 1")
        # Invariants:
        #   get_semaphore.value() == len(self._data)
        #   put_semaphore.value() + get_semaphore.value() = capacity
        self.capacity = operator.index(capacity)
        self._put_semaphore = Semaphore(capacity, max_value=capacity)
        self._get_semaphore = Semaphore(0, max_value=capacity)
        self._data = deque()
        self._join_lot = _core.ParkingLot()
        self._unprocessed = 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号