promise: move constructor out of header
[model-checker.git] / promise.cc
index 69197cbac818b8f8dc01ad75d1d109df61474783..8519feef5e678726b1ea2369e48a35e0d95631bd 100644 (file)
@@ -5,6 +5,22 @@
 #include "model.h"
 #include "schedule.h"
 
+/**
+ * @brief Promise constructor
+ * @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) :
+       num_available_threads(0),
+       value(fv.value),
+       expiration(fv.expiration),
+       read(read),
+       write(NULL)
+{
+       add_thread(fv.tid);
+       eliminate_thread(read->get_tid());
+}
+
 /**
  * Eliminate a thread which no longer can satisfy this promise. Once all
  * enabled threads have been eliminated, this promise is unresolvable.
@@ -59,7 +75,7 @@ bool Promise::thread_is_available(thread_id_t tid) const
 /** @brief Print debug info about the Promise */
 void Promise::print() const
 {
-       model_print("Promised value %#" PRIx64 ", read from thread %d, available threads to resolve: ", value, read->get_tid());
+       model_print("Promised value %#" PRIx64 ", read from thread %d, available threads to resolve: ", value, id_to_int(read->get_tid()));
        for (unsigned int i = 0; i < available_thread.size(); i++)
                if (available_thread[i])
                        model_print("[%d]", i);