def operation_completed(self, transaction: Transaction, scheduler: SchedulerInterface, operation: Operation): assert len(self._ongoing_operation_simulators_queue) > 0 operation_simulator = self._ongoing_operation_simulators_queue[0] # this should be the next awaiting operation assert(operation == operation_simulator.operation) if isinstance(operation_simulator, ReadOperationSimulator): assert operation is not None and operation.get_type() == 'read' assert isinstance(operation, ReadOperation) dest_local_var_name = operation_simulator.dest_local_variable_name self._local_variables[dest_local_var_name] = operation.read_value # print to execution log! SchedulerExecutionLogger.transaction_action(scheduler, self, operation_simulator) if scheduler is not None: SchedulerExecutionLogger.print_variables(scheduler) popped_operation_simulator = self._ongoing_operation_simulators_queue.pop(0) # remove list head assert popped_operation_simulator == operation_simulator self._completed_operation_simulators_queue.append(operation_simulator)
def add_operation(self, operation: Operation): assert not self._is_read_only or operation.get_type() != 'write' self._waiting_operations_queue.append(operation) operation.transaction_id = self.transaction_id