3 * @brief Promise class --- tracks future obligations for execution
4 * related to weakly ordered writes.
12 #include "modeltypes.h"
14 #include "stl-model.h"
21 modelclock_t expiration;
27 Promise(const ModelExecution *execution, ModelAction *read, struct future_value fv);
28 bool add_reader(ModelAction *reader);
29 ModelAction * get_reader(unsigned int i) const;
30 unsigned int get_num_readers() const { return readers.size(); }
31 bool eliminate_thread(thread_id_t tid);
32 void add_thread(thread_id_t tid);
33 bool thread_is_available(thread_id_t tid) const;
34 bool thread_was_available(thread_id_t tid) const;
35 unsigned int max_available_thread_idx() const;
36 bool has_failed() const;
37 void set_write(const ModelAction *act) { write = act; }
38 const ModelAction * get_write() const { return write; }
39 int get_num_available_threads() const { return num_available_threads; }
40 int get_num_was_available_threads() const { return num_was_available_threads; }
41 bool is_compatible(const ModelAction *act) const;
42 bool is_compatible_exclusive(const ModelAction *act) const;
43 bool same_value(const ModelAction *write) const;
44 bool same_location(const ModelAction *act) const;
46 modelclock_t get_expiration() const { return fv.expiration; }
47 uint64_t get_value() const { return fv.value; }
48 struct future_value get_fv() const { return fv; }
50 int get_index() const;
54 bool equals(const Promise *x) const { return this == x; }
55 bool equals(const ModelAction *x) const { return false; }
59 /** @brief The execution which created this Promise */
60 const ModelExecution *execution;
62 /** @brief Thread ID(s) for thread(s) that potentially can satisfy this
64 SnapVector<bool> available_thread;
65 SnapVector<bool> was_available_thread;
67 int num_available_threads;
68 int num_was_available_threads;
70 const future_value fv;
72 /** @brief The action(s) which read the promised future value */
73 SnapVector<ModelAction *> readers;
75 const ModelAction *write;