promise: rename has_sync_thread() -> thread_is_eliminated()
[model-checker.git] / promise.cc
index 943a0f4f9ba09f1d7a7c67521b1c570ca6db0bf2..3b2aa960f967bb389d48b24fe61e0d4f62664471 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;
-       unsigned int sync_size = synced_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))) {
-                       return false;
-               }
-       }
-       return true;
+       eliminated_thread[id] = true;
+       return has_failed();
 }
 
-bool Promise::check_promise() const
+/**
+ * Check if this promise has failed. A promise can fail when all threads which
+ * could possibly satisfy the promise have been eliminated.
+ *
+ * @return True, if this promise has failed; false otherwise
+ */
+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]) && 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;
                }
        }