diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-10-02 10:43:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-02 10:43:42 -0700 |
commit | bbd4ae1bc12dc6b34d4a455015096b7113a5cec5 (patch) | |
tree | 1d91babfa3fdfe47d0a3b01809081150ede27628 /tests/napi/uv_test.js | |
parent | 1837aed79b77b3137563d4730d02e466c85b2b87 (diff) |
fix(node): implement libuv APIs needed to support `npm:sqlite3` (#25893)
Fixes #24740.
Implements the `uv_mutex_*` and `uv_async_*` APIs.
The mutex API is implemented exactly as libuv, a thin wrapper over the
OS's native mutex.
The async API is implemented in terms of napi_async_work. As documented
in the napi docs, you really shouldn't call `napi_queue_async_work`
multiple times (it is documented as undefined behavior). However, our
implementation doesn't have any issue with this, so I believe it suits
our purpose here.
Diffstat (limited to 'tests/napi/uv_test.js')
-rw-r--r-- | tests/napi/uv_test.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/napi/uv_test.js b/tests/napi/uv_test.js new file mode 100644 index 000000000..6d8ee2671 --- /dev/null +++ b/tests/napi/uv_test.js @@ -0,0 +1,18 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +import { assertEquals, loadTestLibrary } from "./common.js"; + +const uv = loadTestLibrary(); + +Deno.test("napi uv async", async () => { + let called = false; + await new Promise((resolve) => { + uv.test_uv_async((value) => { + called = true; + if (value === 5) { + resolve(); + } + }); + }); + assertEquals(called, true); +}); |