From 5467ad92b9043ee54e3c64d661277751c43a355f Mon Sep 17 00:00:00 2001
From: Brian Norris <banorris@uci.edu>
Date: Fri, 1 Feb 2013 15:09:07 -0800
Subject: [PATCH] cyclegraph: add CycleNode::resolvePromise(),
 CycleNode::getPromise()

---
 cyclegraph.cc | 16 ++++++++++++++++
 cyclegraph.h  |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/cyclegraph.cc b/cyclegraph.cc
index 58cb79f..479ddf8 100644
--- a/cyclegraph.cc
+++ b/cyclegraph.cc
@@ -429,3 +429,19 @@ bool CycleNode::setRMW(CycleNode *node)
 	hasRMW = node;
 	return false;
 }
+
+/**
+ * Convert a Promise CycleNode into a concrete-valued CycleNode. Should only be
+ * used when there's no existing ModelAction CycleNode for this write.
+ *
+ * @param writer The ModelAction which wrote the future value represented by
+ * this CycleNode
+ */
+void CycleNode::resolvePromise(const ModelAction *writer)
+{
+	ASSERT(is_promise());
+	ASSERT(promise->is_compatible(writer));
+	action = writer;
+	promise = NULL;
+	ASSERT(!is_promise());
+}
diff --git a/cyclegraph.h b/cyclegraph.h
index 4a3d083..e7e9380 100644
--- a/cyclegraph.h
+++ b/cyclegraph.h
@@ -89,12 +89,14 @@ class CycleNode {
 	CycleNode * getRMW() const;
 	void clearRMW() { hasRMW = NULL; }
 	const ModelAction * getAction() const { return action; }
+	const Promise * getPromise() const { return promise; }
 
 	void popEdge() {
 		edges.pop_back();
 	}
 
 	bool is_promise() const { return !action; }
+	void resolvePromise(const ModelAction *writer);
 
 	SNAPSHOTALLOC
  private:
-- 
2.34.1