-/**
- * Checks whether one CycleNode can reach another.
- * @param from The CycleNode from which to begin exploration
- * @param to The CycleNode to reach
- * @return True, @a from can reach @a to; otherwise, false
- */
-bool CycleGraph::checkReachable(const CycleNode *from, const CycleNode *to) const
-{
- std::vector< const CycleNode *, ModelAlloc<const CycleNode *> > queue;
- discovered->reset();
-
- queue.push_back(from);
- discovered->put(from, from);
- while (!queue.empty()) {
- const CycleNode *node = queue.back();
- queue.pop_back();
- if (node == to)
- return true;
-
- for (unsigned int i = 0; i < node->getNumEdges(); i++) {
- CycleNode *next = node->getEdge(i);
- if (!discovered->contains(next)) {
- discovered->put(next, next);
- queue.push_back(next);
- }
- }
- }
- return false;
-}
-
-bool CycleGraph::checkPromise(const ModelAction *fromact, Promise *promise) const
-{
- std::vector< CycleNode *, ModelAlloc<CycleNode *> > queue;
- discovered->reset();
- CycleNode *from = actionToNode.get(fromact);
-
- queue.push_back(from);
- discovered->put(from, from);
- while (!queue.empty()) {
- CycleNode *node = queue.back();
- queue.pop_back();
-
- if (promise->increment_threads(node->getAction()->get_tid())) {
- return true;
- }
-
- for (unsigned int i = 0; i < node->getNumEdges(); i++) {
- CycleNode *next = node->getEdge(i);
- if (!discovered->contains(next)) {
- discovered->put(next, next);
- queue.push_back(next);
- }
- }
- }
- return false;
-}
-
-void CycleGraph::startChanges()
-{
- ASSERT(rollbackvector.size() == 0);
- ASSERT(rmwrollbackvector.size() == 0);
- ASSERT(oldCycles == hasCycles);
- ASSERT(oldRMWViolation == hasRMWViolation);
-}
-
-/** Commit changes to the cyclegraph. */
-void CycleGraph::commitChanges()
-{
- rollbackvector.resize(0);
- rmwrollbackvector.resize(0);
- oldCycles = hasCycles;
- oldRMWViolation = hasRMWViolation;
-}
-
-/** Rollback changes to the previous commit. */
-void CycleGraph::rollbackChanges()
-{
- for (unsigned int i = 0; i < rollbackvector.size(); i++) {
- rollbackvector[i]->popEdge();
- }
-
- for (unsigned int i = 0; i < rmwrollbackvector.size(); i++) {
- rmwrollbackvector[i]->clearRMW();
- }
-
- hasCycles = oldCycles;
- hasRMWViolation = oldRMWViolation;
- rollbackvector.resize(0);
- rmwrollbackvector.resize(0);
-}
-
-/** @returns whether a CycleGraph contains cycles. */
-bool CycleGraph::checkForCycles() const
-{
- return hasCycles;
-}
-
-bool CycleGraph::checkForRMWViolation() const
-{
- return hasRMWViolation;
-}
-