def __tx_add_undocopy(self): ''' Start consistent transaction (very basic copy-off undo-log) ''' name = self.name + '-' + str(len(self.tx_log)) + '-tx' (tx_handle, mem) = self.memory_resource._MemoryResource_create_named_memory( name, len(self.memory_view)) if tx_handle is None: raise RuntimeError('tx_begin failed') self.tx_log.append((tx_handle, name)) # copy data, then persist mem[:] = self.memory_view self.memory_resource._MemoryResource_persist_memory_view( self.memory_view) print('tx_begin: copy of {}:{} to ({}, {})'.format( hex(pymmcore.memoryview_addr(self.memory_view)), len(self.memory_view), name, hex(pymmcore.memoryview_addr(mem))))
def __tx_begin_swcopy(self): ''' Start consistent transaction (very basic copy-off undo-log) ''' (self.tx_handle, mem) = self.mr._MemoryResource_create_named_memory(self.varname + '-tx', len(self.buffer)) if self.tx_handle is None: raise RuntimeError('tx_begin failed') # copy data, then persist mem[:]= self.buffer; self.mr._MemoryResource_persist_memory_view(mem) if self._debug_level > 0: print('tx_begin: copy @ {}'.format(hex(pymmcore.memoryview_addr(mem)), len(mem)))
def __del__(self): if self._debug_level > 0: print("releasing named memory {} @ {}".format( self.varname, hex(pymmcore.memoryview_addr(self.buffer)))) self.persist() self.mr.release_named_memory_by_handle(self.handle)
def addr(self): ''' For debugging. Get address of memory view ''' return (hex(pymmcore.memoryview_addr(self.buffer)), len(self.buffer))