From bece1ce05704d9a81efd2e04a22ee721795903e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 28 Dec 2022 10:29:48 +0100 Subject: feat(unstable): Add Deno.Conn.ref()/unref() (#17170) This commit adds "Deno.Conn.ref()" and "Deno.Conn.unref()" methods. These methods can be used to make connection block or not block the event loop from finishing. Refing/unrefing only influences "read" operations - ie. scheduling writes to a connection _do_ keep event loop alive. Required for https://github.com/denoland/deno/issues/16710 --- ext/net/lib.deno_net.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ext/net/lib.deno_net.d.ts') diff --git a/ext/net/lib.deno_net.d.ts b/ext/net/lib.deno_net.d.ts index 639d0f8af..136723262 100644 --- a/ext/net/lib.deno_net.d.ts +++ b/ext/net/lib.deno_net.d.ts @@ -61,6 +61,20 @@ declare namespace Deno { * callers should just use `close()`. */ closeWrite(): Promise; + /** **UNSTABLE**: New API, yet to be vetted. + * + * Make the connection block the event loop from finishing. + * + * Note: the connection blocks the event loop from finishing by default. + * This method is only meaningful after `.unref()` is called. + */ + ref(): void; + /** **UNSTABLE**: New API, yet to be vetted. + * + * Make the connection not block the event loop from finishing. + */ + unref(): void; + readonly readable: ReadableStream; readonly writable: WritableStream; } -- cgit v1.2.3