Skip to content

Commit

Permalink
Call .ref() and .unref() instead of `Deno.UnsafeCallback.threadSa…
Browse files Browse the repository at this point in the history
…fe()`
  • Loading branch information
rojvv committed Mar 27, 2023
1 parent cfd443c commit 05ba8c5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/future.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { checkFDBErr, PointerContainer } from "./utils.ts";

export class Future {
private static FUTURE_CALLBACK_MAP = new Map<number | bigint, Future>();
private static FUTURE_CALLBACK = Deno.UnsafeCallback.threadSafe(
private static FUTURE_CALLBACK = new Deno.UnsafeCallback(
{ parameters: ["pointer", "pointer"], result: "void" },
(pointer) => {
if (!pointer) {
Expand All @@ -13,6 +13,7 @@ export class Future {
const future = Future.FUTURE_CALLBACK_MAP.get(pointerValue);
if (future) {
Future.FUTURE_CALLBACK_MAP.delete(pointerValue);
Future.FUTURE_CALLBACK.unref();
future.callback?.(future);
}
},
Expand Down Expand Up @@ -47,6 +48,7 @@ export class Future {
null,
),
);
Future.FUTURE_CALLBACK.ref();
}

getError() {
Expand Down

0 comments on commit 05ba8c5

Please sign in to comment.