Add a simple add/remove counter to record when threads are 'added' and
'removed' from the backtracking set.
: action(act),
num_threads(nthreads),
explored_children(num_threads),
- backtrack(num_threads)
+ backtrack(num_threads),
+ numBacktracks(0)
{
}
*/
bool Node::backtrack_empty()
{
- unsigned int i;
- for (i = 0; i < backtrack.size(); i++)
- if (backtrack[i] == true)
- return false;
- return true;
+ return numBacktracks == 0;
}
/**
if (backtrack[i])
return false;
backtrack[i] = true;
+ numBacktracks++;
return true;
}
if (i >= backtrack.size())
return THREAD_ID_T_NONE;
backtrack[i] = false;
+ numBacktracks--;
return int_to_id(i);
}
void Node::explore(thread_id_t tid)
{
int i = id_to_int(tid);
- backtrack[i] = false;
+ if (backtrack[i]) {
+ backtrack[i] = false;
+ numBacktracks--;
+ }
explored_children[i] = true;
}
int num_threads;
std::vector< bool, MyAlloc<bool> > explored_children;
std::vector< bool, MyAlloc<bool> > backtrack;
+ int numBacktracks;
};
typedef std::list<class Node *, MyAlloc< class Node * > > node_list_t;