X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=promise.h;h=5b0e356bc6873238765577cab957977dc8c8a143;hb=3f77119600ac3aa246258dec2776056d09f8e4e0;hp=e040e169e83e1657f53230c107f7805b8416fc2e;hpb=00b14c0561d3838aeb798d3c22f4136f8c4d136b;p=model-checker.git diff --git a/promise.h b/promise.h index e040e16..5b0e356 100644 --- a/promise.h +++ b/promise.h @@ -8,10 +8,12 @@ #define __PROMISE_H__ #include -#include "threads-model.h" +#include -#include "model.h" #include "modeltypes.h" +#include "mymemory.h" + +class ModelAction; struct future_value { uint64_t value; @@ -21,27 +23,21 @@ struct future_value { class Promise { public: - Promise(ModelAction *read, struct future_value fv) : - num_available_threads(0), - value(fv.value), - expiration(fv.expiration), - read(read), - write(NULL) - { - add_thread(fv.tid); - eliminate_thread(read->get_tid()); - } - modelclock_t get_expiration() const { return expiration; } + Promise(ModelAction *read, struct future_value fv); ModelAction * get_action() const { return read; } bool eliminate_thread(thread_id_t tid); void add_thread(thread_id_t tid); bool thread_is_available(thread_id_t tid) const; bool has_failed() const; - uint64_t get_value() const { return value; } void set_write(const ModelAction *act) { write = act; } const ModelAction * get_write() const { return write; } int get_num_available_threads() const { return num_available_threads; } - bool is_compatible(const ModelAction *write) const; + bool is_compatible(const ModelAction *act) const; + bool is_compatible_exclusive(const ModelAction *act) const; + + modelclock_t get_expiration() const { return fv.expiration; } + uint64_t get_value() const { return fv.value; } + struct future_value get_fv() const { return fv; } void print() const; @@ -53,8 +49,7 @@ class Promise { int num_available_threads; - const uint64_t value; - const modelclock_t expiration; + const future_value fv; /** @brief The action which reads a promised value */ ModelAction * const read;