From 144f1b806679fd9030147f554513d7fce36f65dc Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 15 Apr 2013 19:25:46 -0700 Subject: [PATCH] promise: get reference to ModelExecution --- execution.cc | 2 +- model.h | 1 - promise.cc | 8 +++++--- promise.h | 6 +++++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/execution.cc b/execution.cc index dc1b6c5..0ec1390 100644 --- a/execution.cc +++ b/execution.cc @@ -616,7 +616,7 @@ bool ModelExecution::process_read(ModelAction *curr) case READ_FROM_FUTURE: { /* Read from future value */ struct future_value fv = node->get_future_value(); - Promise *promise = new Promise(curr, fv); + Promise *promise = new Promise(this, curr, fv); curr->set_read_from_promise(promise); promises->push_back(promise); mo_graph->startChanges(); diff --git a/model.h b/model.h index dd5df93..4dbe557 100644 --- a/model.h +++ b/model.h @@ -54,7 +54,6 @@ public: Thread * get_thread(thread_id_t tid) const; Thread * get_thread(const ModelAction *act) const; - int get_promise_number(const Promise *promise) const; bool is_enabled(Thread *t) const; bool is_enabled(thread_id_t tid) const; diff --git a/promise.cc b/promise.cc index 29e261f..df86090 100644 --- a/promise.cc +++ b/promise.cc @@ -2,17 +2,19 @@ #include #include "promise.h" -#include "model.h" +#include "execution.h" #include "schedule.h" #include "action.h" #include "threads-model.h" /** * @brief Promise constructor + * @param execution The execution which is creating this Promise * @param read The read which reads from a promised future value * @param fv The future value that is promised */ -Promise::Promise(ModelAction *read, struct future_value fv) : +Promise::Promise(const ModelExecution *execution, ModelAction *read, struct future_value fv) : + execution(execution), num_available_threads(0), fv(fv), readers(1, read), @@ -170,5 +172,5 @@ bool Promise::same_location(const ModelAction *act) const /** @brief Get this Promise's index within the execution's promise array */ int Promise::get_index() const { - return model->get_promise_number(this); + return execution->get_promise_number(this); } diff --git a/promise.h b/promise.h index e8c233c..1560b58 100644 --- a/promise.h +++ b/promise.h @@ -14,6 +14,7 @@ #include "stl-model.h" class ModelAction; +class ModelExecution; struct future_value { uint64_t value; @@ -23,7 +24,7 @@ struct future_value { class Promise { public: - Promise(ModelAction *read, struct future_value fv); + Promise(const ModelExecution *execution, ModelAction *read, struct future_value fv); bool add_reader(ModelAction *reader); ModelAction * get_reader(unsigned int i) const; unsigned int get_num_readers() const { return readers.size(); } @@ -52,6 +53,9 @@ class Promise { SNAPSHOTALLOC private: + /** @brief The execution which created this Promise */ + const ModelExecution *execution; + /** @brief Thread ID(s) for thread(s) that potentially can satisfy this * promise */ SnapVector available_thread; -- 2.34.1