+/**
+ * Returns the clock vector for a given thread.
+ * @param tid The thread whose clock vector we want
+ * @return Desired clock vector
+ */
+ClockVector * ModelChecker::get_cv(thread_id_t tid) {
+ return get_parent_action(tid)->get_cv();
+}
+
+
+/** Resolve promises. */
+
+void ModelChecker::resolve_promises(ModelAction *write) {
+ for(unsigned int i=0;i<promises->size();i++) {
+ Promise * promise=(*promises)[i];
+ if (write->get_node()->get_promise(i)) {
+ ModelAction * read=promise->get_action();
+ read->read_from(write);
+ r_modification_order(read, write);
+ }
+ }
+}
+
+void ModelChecker::compute_promises(ModelAction *curr) {
+ for(unsigned int i=0;i<promises->size();i++) {
+ Promise * promise=(*promises)[i];
+ const ModelAction * act=promise->get_action();
+ if (!act->happens_before(curr)&&
+ act->is_read()&&
+ !act->is_synchronizing(curr)&&
+ !act->same_thread(curr)&&
+ promise->get_value()==curr->get_value()) {
+ curr->get_node()->set_promise(i);
+ }
+ }
+}
+
+/** Checks promises in response to change in ClockVector Threads. */
+
+void ModelChecker::check_promises(ClockVector *old_cv, ClockVector * merge_cv) {
+ for(unsigned int i=0;i<promises->size();i++) {
+ Promise * promise=(*promises)[i];
+ const ModelAction * act=promise->get_action();
+ if ((old_cv==NULL||!old_cv->synchronized_since(act))&&
+ merge_cv->synchronized_since(act)) {
+ //This thread is no longer able to send values back to satisfy the promise
+ int num_synchronized_threads=promise->increment_threads();
+ if (num_synchronized_threads==model->get_num_threads()) {
+ //Promise has failed
+ failed_promise = true;
+ return;
+ }
+ }
+ }
+}
+