Пример #1
0
void
process_unset(vector<string> cmd_str) {
	
	int val;
	int prev_tid, prev_val_tid;
	int prev_var_val_cnt, prev_var_val;
	
	Transaction* t = trans_stack.back();
	t->clear_value(cmd_str[1]);

	// if the variable was modified last in another transaction, add this transaction to the 
	// var_tid_stack
	if ( (!var_tid_stack[cmd_str[1]].empty()) && (t->get_tid() != var_tid_stack[cmd_str[1]].back())) {

		prev_tid = var_tid_stack[cmd_str[1]].back();
		prev_var_val = trans_stack[prev_tid]->get_value(cmd_str[1]);
		if (!val_tid_stack[prev_var_val].empty()) {
			prev_val_tid = val_tid_stack[prev_var_val].back();
		}
		prev_var_val_cnt = trans_stack[prev_val_tid]->get_valMap_value(prev_var_val);
		var_tid_stack[cmd_str[1]].push_back(t->get_tid());
		

		// we need a new label -9999 to indicate that the variable was unset
		// for process_get aka displaying purposes; use it to update current transaction
		t->add_value(cmd_str[1], -9999);
		
		//if value of var is 0, then look for previous tid count and add that to the present tid

		if (prev_var_val != -1) {
			//the prev var value has changed so add current tid to the val_tid_stack
			val_tid_stack[prev_var_val].push_back(t->get_tid());				
			t->set_valMap_value(prev_var_val, --prev_var_val_cnt);
		}

		
	}	

}