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:
Bartek Iwańczuk 2020-12-16 17:14:12 +01:00 committed by GitHub
parent 9fe26f8ca1
commit 6984b63f2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 1237 additions and 1221 deletions

View file

@ -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();