1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-21 23:04:45 -05:00

Make shutdown unstable and async (#4940)

This commit is contained in:
Luca Casonato 2020-04-28 07:36:47 +02:00 committed by GitHub
parent de751e5221
commit 30dc9bb748
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View file

@ -1872,7 +1872,7 @@ declare namespace Deno {
* const conn = await listener.accept();
* Deno.shutdown(conn.rid, Deno.ShutdownMode.Write);
*/
export function shutdown(rid: number, how: ShutdownMode): void;
export function shutdown(rid: number, how: ShutdownMode): Promise<void>;
/** **UNSTABLE**: new API, yet to be vetted.
*

View file

@ -22,8 +22,9 @@ export enum ShutdownMode {
ReadWrite, // unused
}
export function shutdown(rid: number, how: ShutdownMode): void {
export function shutdown(rid: number, how: ShutdownMode): Promise<void> {
sendSync("op_shutdown", { rid, how });
return Promise.resolve();
}
interface AcceptResponse {

View file

@ -342,10 +342,12 @@ struct ShutdownArgs {
fn op_shutdown(
isolate: &mut CoreIsolate,
_state: &State,
state: &State,
args: Value,
_zero_copy: Option<ZeroCopyBuf>,
) -> Result<JsonOp, OpError> {
state.check_unstable("Deno.shutdown");
let args: ShutdownArgs = serde_json::from_value(args)?;
let rid = args.rid as u32;