Website Summary Files Commits Branches @commit @diff @stats
path: root / gctest / gc.h
diff options
context:
space:
mode:
Commitb96d8490dbbd4c9b3cf231fa4e2b5ab87b376a25 (patch)
Author
 Dimitar Trendafilov <trendafilov.dn@gmail.com>
2020-12-24 14:18:18 +0200
Committer
 Dimitar Trendafilov <trendafilov.dn@gmail.com>
2021-09-13 22:25:45 +0300
Files432b7dc3ddc6e93aa6c160761852a81fdbe6588c /gctest/gc.h
IPL-b96d8490dbbd4c9b3cf231fa4e2b5ab87b376a25.tar
IPL-b96d8490dbbd4c9b3cf231fa4e2b5ab87b376a25.tar.gz
IPL-b96d8490dbbd4c9b3cf231fa4e2b5ab87b376a25.zip
Parent1f9b498405be032de2422440577f9a04dc7ad066 (diff)
Allow for copying collectors to be implemented
1 files changed, 7 insertions, 5 deletions
-rw-r--r--gctest/gc.h12
diff --git a/gctest/gc.h b/gctest/gc.h
index 42612ed..fcd180e 100644
--- a/gctest/gc.h
+++ b/gctest/gc.h
@@ -17,7 +17,8 @@ class ObjectVisitor
public:
virtual ~ObjectVisitor() {}
- virtual void VisitReference(Object* from, Object* to, void* state) = 0;
+ // Object** to allows the reference to be moved
+ virtual void VisitReference(Object* from, Object** to, void* state) = 0;
};
class GarbageCollector : public ObjectVisitor
@@ -25,7 +26,8 @@ class GarbageCollector : public ObjectVisitor
public:
virtual void* Allocate(size_t size) = 0;
- virtual void SetRoot(Object* root) = 0;
+ // Object** to allows the root to be moved
+ virtual void SetRoot(Object** root) = 0;
virtual void Shutdown() = 0;
};
@@ -43,11 +45,11 @@ public:
}
}
- void VisitReference(Object*, Object* to, void*) override
+ void VisitReference(Object*, Object** to, void*) override
{
- if (to)
+ if (*to)
{
- Destroy(to);
+ Destroy(*to);
}
}
std::unordered_set<Object*> m_Visited;