void ModelAction::set_read_from(const ModelAction *act)
{
reads_from = act;
+ reads_from_promise = NULL;
if (act && act->is_uninitialized())
model->assert_bug("May read from uninitialized atomic\n");
}
+/**
+ * Set this action's read-from promise
+ * @param promise The promise to read from
+ */
+void ModelAction::set_read_from_promise(const Promise *promise)
+{
+ ASSERT(is_read());
+ reads_from_promise = promise;
+ reads_from = NULL;
+}
+
/**
* Synchronize the current thread with the thread corresponding to the
* ModelAction parameter.
class ClockVector;
class Thread;
+class Promise;
using std::memory_order;
using std::memory_order_relaxed;
void * get_location() const { return location; }
modelclock_t get_seq_number() const { return seq_number; }
uint64_t get_value() const { return value; }
- void set_value(uint64_t v) { value = v; }
const ModelAction * get_reads_from() const { return reads_from; }
+ const Promise * get_reads_from_promise() const { return reads_from_promise; }
Node * get_node() const;
void set_node(Node *n) { node = n; }
void set_read_from(const ModelAction *act);
+ void set_read_from_promise(const Promise *promise);
/** Store the most recent fence-release from the same thread
* @param fence The fence-release that occured prior to this */
/** The action that this action reads from. Only valid for reads */
const ModelAction *reads_from;
+ /** The promise that this action reads from. Only valid for reads */
+ const Promise *reads_from_promise;
+
/** The last fence release from the same thread */
const ModelAction *last_fence_release;
} else if (!second_part_of_rmw) {
/* Read from future value */
struct future_value fv = curr->get_node()->get_future_value();
+ Promise *promise = new Promise(curr, fv);
value = fv.value;
- curr->set_value(fv.value);
- curr->set_read_from(NULL);
- promises->push_back(new Promise(curr, fv));
+ curr->set_read_from_promise(promise);
+ promises->push_back(promise);
}
get_thread(curr)->set_return_value(value);
return updated;