mutex: change 'islocked' to hold Thread pointer
[c11tester.git] / nodestack.cc
index 131b06ca6fe1d190ed56f74577676cc81cc3b069..01273479a69ed90919c3b60765fe8a814d2a584b 100644 (file)
@@ -285,6 +285,7 @@ void Node::clear_backtracking()
                backtrack[i] = false;
        for (unsigned int i = 0; i < explored_children.size(); i++)
                explored_children[i] = false;
+       numBacktracks = 0;
 }
 
 bool Node::is_enabled(Thread *t) const
@@ -455,13 +456,30 @@ void Node::add_read_from_promise(const ModelAction *reader)
  * where this->action is a 'read'.
  * @return The current element in read_from_promises
  */
-const Promise * Node::get_read_from_promise() const
+Promise * Node::get_read_from_promise() const
 {
-       if (read_from_promise_idx < 0 || read_from_promise_idx >= ((int)read_from_promises.size()))
-               return NULL;
+       ASSERT(read_from_promise_idx >= 0 && read_from_promise_idx < ((int)read_from_promises.size()));
        return read_from_promises[read_from_promise_idx]->get_reads_from_promise();
 }
 
+/**
+ * Gets a particular 'read-from-promise' form this Node. Only vlaid for a node
+ * where this->action is a 'read'.
+ * @param i The index of the Promise to get
+ * @return The Promise at index i, if the Promise is still available; NULL
+ * otherwise
+ */
+Promise * Node::get_read_from_promise(int i) const
+{
+       return read_from_promises[i]->get_reads_from_promise();
+}
+
+/** @return The size of the read-from-promise set */
+int Node::get_read_from_promise_size() const
+{
+       return read_from_promises.size();
+}
+
 /**
  * Checks whether the read_from_promises set for this node is empty.
  * @return true if the read_from_promises set is empty.