From: Brian Demsky Date: Thu, 12 Dec 2019 23:34:37 +0000 (-0800) Subject: Add ref counts to CycleGraph X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7d1b8dbe8d1839862c3db07e67a313d0e6efce81;p=c11tester.git Add ref counts to CycleGraph --- diff --git a/cyclegraph.cc b/cyclegraph.cc index 79030985..f8d3b852 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -131,6 +131,7 @@ void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) if (tonode != rmwnode) { rmwnode->addEdge(tonode); } + tonode->refcount--; } fromnode->edges.clear(); @@ -297,7 +298,8 @@ bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) CycleNode::CycleNode(const ModelAction *act) : action(act), hasRMW(NULL), - cv(new ClockVector(NULL, act)) + cv(new ClockVector(NULL, act)), + refcount(0) { } @@ -316,20 +318,6 @@ unsigned int CycleNode::getNumEdges() const return edges.size(); } -/** - * @brief Remove a (forward) edge from this CycleNode - * @return The CycleNode which was popped, if one exists; otherwise NULL - */ -CycleNode * CycleNode::removeEdge() -{ - if (edges.empty()) - return NULL; - - CycleNode *ret = edges.back(); - edges.pop_back(); - return ret; -} - /** * Adds an edge from this CycleNode to another CycleNode. * @param node The node to which we add a directed edge @@ -341,6 +329,7 @@ void CycleNode::addEdge(CycleNode *node) if (edges[i] == node) return; edges.push_back(node); + node->refcount++; } /** @returns the RMW CycleNode that reads from the current CycleNode */ diff --git a/cyclegraph.h b/cyclegraph.h index 3ea4e3bb..c9481b78 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -63,7 +63,6 @@ public: void addEdge(CycleNode *node); CycleNode * getEdge(unsigned int i) const; unsigned int getNumEdges() const; - CycleNode * removeEdge(); bool setRMW(CycleNode *); CycleNode * getRMW() const; void clearRMW() { hasRMW = NULL; } @@ -84,6 +83,9 @@ private: /** ClockVector for this Node. */ ClockVector *cv; friend class CycleGraph; + + /** @brief Reference count to node. */ + int refcount; }; #endif /* __CYCLEGRAPH_H__ */