mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
refactor: rewrite ops to use ResourceTable2 (#8512)
This commit migrates all ops to use new resource table and "AsyncRefCell". Old implementation of resource table was completely removed and all code referencing it was updated to use new system.
This commit is contained in:
parent
9fe26f8ca1
commit
6984b63f2f
26 changed files with 1237 additions and 1221 deletions
|
@ -21,8 +21,6 @@ unitTest({ perms: { net: true } }, function netTcpListenClose(): void {
|
|||
unitTest(
|
||||
{
|
||||
perms: { net: true },
|
||||
// TODO:
|
||||
ignore: Deno.build.os === "windows",
|
||||
},
|
||||
function netUdpListenClose(): void {
|
||||
const socket = Deno.listenDatagram({
|
||||
|
@ -257,7 +255,7 @@ unitTest(
|
|||
);
|
||||
|
||||
unitTest(
|
||||
{ ignore: Deno.build.os === "windows", perms: { net: true } },
|
||||
{ perms: { net: true } },
|
||||
async function netUdpSendReceive(): Promise<void> {
|
||||
const alice = Deno.listenDatagram({ port: 3500, transport: "udp" });
|
||||
assert(alice.addr.transport === "udp");
|
||||
|
@ -287,7 +285,31 @@ unitTest(
|
|||
);
|
||||
|
||||
unitTest(
|
||||
{ ignore: Deno.build.os === "windows", perms: { net: true } },
|
||||
{ perms: { net: true } },
|
||||
async function netUdpConcurrentSendReceive(): Promise<void> {
|
||||
const socket = Deno.listenDatagram({ port: 3500, transport: "udp" });
|
||||
assert(socket.addr.transport === "udp");
|
||||
assertEquals(socket.addr.port, 3500);
|
||||
assertEquals(socket.addr.hostname, "127.0.0.1");
|
||||
|
||||
const recvPromise = socket.receive();
|
||||
|
||||
const sendBuf = new Uint8Array([1, 2, 3]);
|
||||
const sendLen = await socket.send(sendBuf, socket.addr);
|
||||
assertEquals(sendLen, 3);
|
||||
|
||||
const [recvBuf, recvAddr] = await recvPromise;
|
||||
assertEquals(recvBuf.length, 3);
|
||||
assertEquals(1, recvBuf[0]);
|
||||
assertEquals(2, recvBuf[1]);
|
||||
assertEquals(3, recvBuf[2]);
|
||||
|
||||
socket.close();
|
||||
},
|
||||
);
|
||||
|
||||
unitTest(
|
||||
{ perms: { net: true } },
|
||||
async function netUdpBorrowMutError(): Promise<void> {
|
||||
const socket = Deno.listenDatagram({
|
||||
port: 4501,
|
||||
|
@ -335,6 +357,34 @@ unitTest(
|
|||
},
|
||||
);
|
||||
|
||||
// TODO(piscisaureus): Enable after Tokio v0.3/v1.0 upgrade.
|
||||
unitTest(
|
||||
{ ignore: true, perms: { read: true, write: true } },
|
||||
async function netUnixPacketConcurrentSendReceive(): Promise<void> {
|
||||
const filePath = await Deno.makeTempFile();
|
||||
const socket = Deno.listenDatagram({
|
||||
path: filePath,
|
||||
transport: "unixpacket",
|
||||
});
|
||||
assert(socket.addr.transport === "unixpacket");
|
||||
assertEquals(socket.addr.path, filePath);
|
||||
|
||||
const recvPromise = socket.receive();
|
||||
|
||||
const sendBuf = new Uint8Array([1, 2, 3]);
|
||||
const sendLen = await socket.send(sendBuf, socket.addr);
|
||||
assertEquals(sendLen, 3);
|
||||
|
||||
const [recvBuf, recvAddr] = await recvPromise;
|
||||
assertEquals(recvBuf.length, 3);
|
||||
assertEquals(1, recvBuf[0]);
|
||||
assertEquals(2, recvBuf[1]);
|
||||
assertEquals(3, recvBuf[2]);
|
||||
|
||||
socket.close();
|
||||
},
|
||||
);
|
||||
|
||||
unitTest(
|
||||
{ perms: { net: true } },
|
||||
async function netTcpListenIteratorBreakClosesResource(): Promise<void> {
|
||||
|
@ -385,7 +435,7 @@ unitTest(
|
|||
);
|
||||
|
||||
unitTest(
|
||||
{ ignore: Deno.build.os === "windows", perms: { net: true } },
|
||||
{ perms: { net: true } },
|
||||
async function netUdpListenCloseWhileIterating(): Promise<void> {
|
||||
const socket = Deno.listenDatagram({ port: 8000, transport: "udp" });
|
||||
const nextWhileClosing = socket[Symbol.asyncIterator]().next();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue