-/**
- * Sets a promise to explore meeting with the given node.
- * @param i is the promise index.
- */
-void Node::set_promise(unsigned int i, bool is_rmw)
-{
- if (i >= promises.size())
- promises.resize(i + 1, PROMISE_IGNORE);
- if (promises[i] == PROMISE_IGNORE) {
- promises[i] = PROMISE_UNFULFILLED;
- if (is_rmw)
- promises[i] |= PROMISE_RMW;
- }
-}
-
-/**
- * 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) const
-{
- 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() const
-{
- 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() const
-{
- return misc_index;
-}
-
-bool Node::increment_misc()
-{
- return (misc_index < misc_max) && ((++misc_index) < misc_max);
-}
-
-bool Node::misc_empty() const
-{
- return (misc_index + 1) >= misc_max;
-}