fix bugs with promise check...
[model-checker.git] / promise.cc
index b051ef0..cbd45c2 100644 (file)
@@ -1,8 +1,21 @@
 #include "promise.h"
+#include "model.h"
+#include "schedule.h"
 
-Promise::Promise(ModelAction *act, uint64_t value) {
-       this->value=value;
-       this->read=act;
-       this->numthreads=1;
+bool Promise::increment_threads(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])
+               return false;
+       
+       synced_thread[id]=true;
+       enabled_type_t * enabled=model->get_scheduler()->get_enabled();
+       unsigned int sync_size=synced_thread.size();
+       for(unsigned int i=0;i<model->get_num_threads();i++) {
+               if ((i >= sync_size || !synced_thread[i]) && (enabled[i] != THREAD_DISABLED))
+                       return false;
+       }
+       return true;
 }
-