def __init__(self, cache_file, dirty=False, *args, **kargs): if 'workers' not in kargs: kargs['workers'] = 16 self.done = False self.gbd = GBD(*args, **kargs) self.uuid = self.gbd.uuid self.block_size = self.gbd.block_size self.block_count = self.gbd.block_count self.total_size = self.gbd.total_size self.cache = open(cache_file, 'r+b') self.cache_lock = Lock() self.entry_count = self.calc_entry_count() self.clean_que = RLUQueue(self.entry_count) self.dirty_que = RLUQueue(self.entry_count) self.last_modify = [0] * self.entry_count self.map = {} self.rmap = [self.EMPTY] * self.entry_count self.map_lock = Lock() self.load_cache(dirty) self.wb_sem = Semaphore(8) self.wb_daemon = Thread(target=self.do_writeback) self.wb_daemon.daemon = True self.wb_daemon.start() self.pull_que = TimedPriorityQueue() self.dque_lock = Lock() self.pull_delay_que = {} self.pull_daemon = Thread(target=self.do_pull) self.pull_daemon.daemon = True self.pull_daemon.start() self.done = True