This commit is contained in:
2024-12-18 12:52:31 +08:00
parent 8cb187e395
commit 167fedb776
2 changed files with 3 additions and 12 deletions

View File

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

View File

@@ -150,12 +150,8 @@ class _JSObject extends JSRef {
}
/// JS function wrapper
class _JSFunction extends _JSObject implements JSInvokable, _IsolateEncodable, Finalizable {
_JSFunction(Pointer<JSContext> ctx, Pointer<JSValue> val) : super(ctx, val) {
_finalizer.attach(this, this);
}
static final _finalizer = Finalizer<_JSFunction>((f) => f.free());
class _JSFunction extends _JSObject implements JSInvokable, _IsolateEncodable {
_JSFunction(Pointer<JSContext> ctx, Pointer<JSValue> val) : super(ctx, val);
@override
invoke(List<dynamic> arguments, [dynamic thisVal]) {