promise: move thread_is_eliminated()
[model-checker.git] / promise.cc
index 7b110020cd869514c0f958055fea357f9f3c42ba..7f6f5e7b1823bb5dd3285196ba57f4ee172b0f37 100644 (file)
 bool Promise::eliminate_thread(thread_id_t tid)
 {
        unsigned int id = id_to_int(tid);
-       if (id >= synced_thread.size())
-               synced_thread.resize(id + 1, false);
-       if (synced_thread[id])
+       if (id >= eliminated_thread.size())
+               eliminated_thread.resize(id + 1, false);
+       if (eliminated_thread[id])
                return false;
 
-       synced_thread[id] = true;
+       eliminated_thread[id] = true;
        return has_failed();
 }
 
+/**
+ * Check if a thread has already been eliminated from resolving this
+ * promise
+ * @param tid Thread ID of the thread to check
+ * @return True if the thread is already eliminated; false otherwise
+ */
+bool Promise::thread_is_eliminated(thread_id_t tid) const
+{
+       unsigned int id = id_to_int(tid);
+       if (id >= eliminated_thread.size())
+               return false;
+       return eliminated_thread[id];
+}
+
 /**
  * Check if this promise has failed. A promise can fail when all threads which
  * could possibly satisfy the promise have been eliminated.
@@ -30,10 +44,10 @@ bool Promise::eliminate_thread(thread_id_t tid)
  */
 bool Promise::has_failed() const
 {
-       unsigned int sync_size = synced_thread.size();
+       unsigned int size = eliminated_thread.size();
        int promise_tid = id_to_int(read->get_tid());
        for (unsigned int i = 1; i < model->get_num_threads(); i++) {
-               if ((i >= sync_size || !synced_thread[i]) && ((int)i != promise_tid) && model->is_enabled(int_to_id(i))) {
+               if ((i >= size || !eliminated_thread[i]) && ((int)i != promise_tid) && model->is_enabled(int_to_id(i))) {
                        return false;
                }
        }