this->exploring = NULL;
this->nextThread = THREAD_ID_T_NONE;
- rootNode = new TreeNode(NULL);
+ rootNode = new TreeNode();
currentNode = rootNode;
action_trace = new action_list_t();
}
{
ModelAction *prev;
TreeNode *node;
+ Thread *t = get_thread(act->get_tid());
prev = get_last_conflict(act);
if (prev == NULL)
node = prev->get_node();
/* Check if this has been explored already */
- if (node->hasBeenExplored(act->get_tid()))
+ if (node->hasBeenExplored(t->get_id()))
return;
/* If this is a new backtracking point, mark the tree */
- if (node->setBacktrack(act->get_tid()) != 0)
+ if (node->setBacktrack(t->get_id()) != 0)
return;
DEBUG("Setting backtrack: conflict = %d, instead tid = %d\n",
- prev->get_tid(), act->get_tid());
+ prev->get_tid(), t->get_id());
if (DBG_ENABLED()) {
prev->print();
act->print();
nextThread = advance_backtracking_state();
next->set_node(currentNode);
set_backtracking(next);
- currentNode = currentNode->exploreChild(next->get_tid());
+ currentNode = currentNode->explore_child(next);
this->action_trace->push_back(next);
}
#include "tree.h"
+#include "action.h"
int TreeNode::totalNodes = 0;
-TreeNode::TreeNode(TreeNode *par)
+TreeNode::TreeNode(TreeNode *par, ModelAction *act)
{
TreeNode::totalNodes++;
this->parent = par;
delete it->second;
}
-TreeNode * TreeNode::exploreChild(thread_id_t id)
+TreeNode * TreeNode::explore_child(ModelAction *act)
{
TreeNode *n;
std::set<int>::iterator it;
+ thread_id_t id = act->get_tid();
int i = id_to_int(id);
if (!hasBeenExplored(id)) {
- n = new TreeNode(this);
+ n = new TreeNode(this, act);
children[i] = n;
} else {
n = children[i];
#include <map>
#include "threads.h"
+class ModelAction;
+
/*
* An n-ary tree
*
*/
class TreeNode {
public:
- TreeNode(TreeNode *par);
+ TreeNode(TreeNode *par = NULL, ModelAction *act = NULL);
~TreeNode();
bool hasBeenExplored(thread_id_t id) { return children.find(id_to_int(id)) != children.end(); }
- TreeNode * exploreChild(thread_id_t id);
+ TreeNode * explore_child(ModelAction *act);
thread_id_t getNextBacktrack();
/* Return 1 if already in backtrack, 0 otherwise */