def __init__(self, *, slot_bytes, slot_count):
"""Initializer.
Args:
slot_bytes: The maximum size of slots in the buffer.
slot_count: How many slots should be in the buffer.
"""
self.slot_count = slot_count
self.array = SlotArray(slot_bytes=slot_bytes, slot_count=slot_count)
self.lock = ReadersWriterLock()
# Each reading process may modify its own Pointer while the read
# lock is being held. Each reading process can also load the position
# of the writer, but not load any other readers. Each reading process
# can also load the value of the 'active' count.
self.readers = []
# The writer can load and store the Pointer of all the reader Pointers
# or the writer Pointer while the write lock is held. It can also load
# and store the value of the 'active' acount.
self.writer = Pointer(self.slot_count)
self.active = multiprocessing.RawValue(ctypes.c_uint, 0)
评论列表
文章目录