cyclegraph: map Promises to Promise nodes
authorBrian Norris <banorris@uci.edu>
Tue, 29 Jan 2013 02:48:46 +0000 (18:48 -0800)
committerBrian Norris <banorris@uci.edu>
Wed, 6 Feb 2013 21:44:38 +0000 (13:44 -0800)
cyclegraph.cc
cyclegraph.h

index 49c462f5375c0695bb07d10b18f82ee156a73b29..58cb79f22cdd573acf59e24976014c91731e6e7e 100644 (file)
@@ -47,6 +47,26 @@ CycleNode * CycleGraph::getNode(const ModelAction *action)
 }
 
 /**
+ * @brief Returns a CycleNode corresponding to a promise
+ *
+ * Gets (or creates, if none exist) a CycleNode corresponding to a promised
+ * value.
+ *
+ * @param promise The Promise generated by a reader
+ * @return The CycleNode corresponding to the Promise
+ */
+CycleNode * CycleGraph::getNode(const Promise *promise)
+{
+       const ModelAction *reader = promise->get_action();
+       CycleNode *node = readerToPromiseNode.get(reader);
+       if (node == NULL) {
+               node = new CycleNode(promise);
+               readerToPromiseNode.put(reader, node);
+       }
+       return node;
+}
+
+/*
  * @brief Adds an edge between objects
  *
  * This function will add an edge between any two objects which can be
index f812e24d4986abef6c45780a897e44bcb27bffe0..4a3d083d13c19fb897a29ebe2917af04f0990423 100644 (file)
@@ -45,10 +45,16 @@ class CycleGraph {
        void addNodeEdge(CycleNode *fromnode, CycleNode *tonode);
        void putNode(const ModelAction *act, CycleNode *node);
        CycleNode * getNode(const ModelAction *);
+       CycleNode * getNode(const Promise *promise);
+
        HashTable<const CycleNode *, const CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free> *discovered;
 
        /** @brief A table for mapping ModelActions to CycleNodes */
        HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> actionToNode;
+       /** @brief A table for mapping reader ModelActions to Promise
+        *  CycleNodes */
+       HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> readerToPromiseNode;
+
 #if SUPPORT_MOD_ORDER_DUMP
        std::vector<CycleNode *> nodeList;
 #endif