make JSFunction Finalizable

This commit is contained in:
nyne
2024-11-11 15:10:44 +08:00
parent 8c26510bb6
commit 4ea1e95201
2 changed files with 12 additions and 3 deletions

View File

@@ -27,9 +27,14 @@ abstract class JSRef {
_refCount++;
}
bool _released = false;
void free() {
_refCount--;
if (_refCount < 0) destroy();
if (_refCount < 0 && !_released){
_released = true;
destroy();
}
}
void destroy();