* Sets a promise to explore meeting with the given node.
* @param i is the promise index.
*/
-void Node::set_promise(unsigned int i) {
+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)
+ if (promises[i] == PROMISE_IGNORE) {
promises[i] = PROMISE_UNFULFILLED;
+ if (is_rmw)
+ promises[i] |= PROMISE_RMW;
+ }
}
/**
* @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_FULFILLED);
+ return (i < promises.size()) && ((promises[i] & PROMISE_MASK) == PROMISE_FULFILLED);
}
/**
*/
bool Node::increment_promise() {
DBG();
-
+ unsigned int rmw_count=0;
for (unsigned int i = 0; i < promises.size(); i++) {
- if (promises[i] == PROMISE_UNFULFILLED) {
- promises[i] = PROMISE_FULFILLED;
+ 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_FULFILLED)
- promises[i] = PROMISE_UNFULFILLED;
+ 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;
* @return true if we have explored all promise combinations.
*/
bool Node::promise_empty() {
- for (unsigned int i = 0; i < promises.size();i++)
- if (promises[i] == PROMISE_UNFULFILLED)
+ 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 this isn't a feasible option, keep going
+ if ((rmw_count > 0)&&(promises[i] & PROMISE_RMW))
+ continue;
return false;
+ } else if (promises[i] == (PROMISE_RMW|PROMISE_FULFILLED)) {
+ rmw_count--;
+ }
+ }
return true;
}