+/**
+ * Looks up whether a given promise should be satisfied by this node.
+ * @param i The promise index.
+ * @return true if the promise should be satisfied by the given model action.
+ */
+bool Node::get_promise(unsigned int i) {
+ return (i < promises.size()) && ((promises[i] & PROMISE_MASK) == PROMISE_FULFILLED);
+}
+
+/**
+ * Increments to the next combination of promises.
+ * @return true if we have a valid combination.
+ */
+bool Node::increment_promise() {
+ DBG();
+ unsigned int rmw_count=0;
+ for (unsigned int i = 0; i < promises.size(); i++) {
+ if (promises[i]==(PROMISE_RMW|PROMISE_FULFILLED))
+ rmw_count++;
+ }
+
+ for (unsigned int i = 0; i < promises.size(); i++) {
+ if ((promises[i] & PROMISE_MASK) == PROMISE_UNFULFILLED) {
+ if ((rmw_count > 0) && (promises[i] & PROMISE_RMW)) {
+ //sending our value to two rmws... not going to work..try next combination
+ continue;
+ }
+ promises[i] = (promises[i] & PROMISE_RMW) |PROMISE_FULFILLED;
+ while (i > 0) {
+ i--;
+ if ((promises[i] & PROMISE_MASK) == PROMISE_FULFILLED)
+ promises[i] = (promises[i] & PROMISE_RMW) | PROMISE_UNFULFILLED;
+ }
+ return true;
+ } else if (promises[i] == (PROMISE_RMW|PROMISE_FULFILLED)) {
+ rmw_count--;
+ }
+ }
+ return false;
+}
+
+/**
+ * Returns whether the promise set is empty.
+ * @return true if we have explored all promise combinations.
+ */
+bool Node::promise_empty() {
+ bool fulfilledrmw=false;
+ for (int i = promises.size()-1 ; i>=0; i--) {
+ if (promises[i]==PROMISE_UNFULFILLED)
+ return false;
+ if (!fulfilledrmw && ((promises[i]&PROMISE_MASK)==PROMISE_UNFULFILLED))
+ return false;
+ if (promises[i]==(PROMISE_FULFILLED|PROMISE_RMW))
+ fulfilledrmw=true;
+ }
+ return true;
+}
+
+
+void Node::set_misc_max(int i) {
+ misc_max=i;
+}
+
+int Node::get_misc() {
+ return misc_index;
+}
+
+bool Node::increment_misc() {
+ return (misc_index<misc_max)&&((++misc_index)<misc_max);
+}
+
+bool Node::misc_empty() {
+ return (misc_index+1)>=misc_max;
+}
+
+