promise: fixup style
[cdsspec-compiler.git] / promise.cc
1 #include "promise.h"
2 #include "model.h"
3 #include "schedule.h"
4
5 bool Promise::increment_threads(thread_id_t tid)
6 {
7         unsigned int id = id_to_int(tid);
8         if (id >= synced_thread.size())
9                 synced_thread.resize(id + 1, false);
10         if (synced_thread[id])
11                 return false;
12
13         synced_thread[id] = true;
14         unsigned int sync_size = synced_thread.size();
15         int promise_tid = id_to_int(read->get_tid());
16         for (unsigned int i = 1; i < model->get_num_threads(); i++) {
17                 if ((i >= sync_size || !synced_thread[i]) && ((int)i != promise_tid) && model->is_enabled(int_to_id(i))) {
18                         return false;
19                 }
20         }
21         return true;
22 }
23
24 bool Promise::check_promise() const
25 {
26         unsigned int sync_size = synced_thread.size();
27         for (unsigned int i = 1; i < model->get_num_threads(); i++) {
28                 if ((i >= sync_size || !synced_thread[i]) && model->is_enabled(int_to_id(i))) {
29                         return false;
30                 }
31         }
32         return true;
33 }