+/**
+ * Add a thread which may resolve this promise
+ *
+ * @param tid The thread ID
+ */
+void Promise::add_thread(thread_id_t tid)
+{
+ unsigned int id = id_to_int(tid);
+ if (id >= available_thread.size())
+ available_thread.resize(id + 1, false);
+ if (!available_thread[id]) {
+ available_thread[id] = true;
+ num_available_threads++;
+ }
+}
+
+/**
+ * Check if a thread is available for resolving this promise. That is, the
+ * thread must have been previously marked for resolving this promise, and it
+ * cannot have been eliminated due to synchronization, etc.
+ *
+ * @param tid Thread ID of the thread to check
+ * @return True if the thread is available; false otherwise
+ */
+bool Promise::thread_is_available(thread_id_t tid) const
+{
+ unsigned int id = id_to_int(tid);
+ if (id >= available_thread.size())
+ return false;
+ return available_thread[id];
+}
+
+/** @brief Print debug info about the Promise */
+void Promise::print() const
+{
+ model_print("Promised value %#" PRIx64 ", first read from thread %d, available threads to resolve: ",
+ fv.value, id_to_int(get_reader(0)->get_tid()));
+ bool failed = true;
+ for (unsigned int i = 0; i < available_thread.size(); i++)
+ if (available_thread[i]) {
+ model_print("[%d]", i);
+ failed = false;
+ }
+ if (failed)
+ model_print("(none)");
+ model_print("\n");
+}
+