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:
parent
de751e5221
commit
30dc9bb748
3 changed files with 6 additions and 3 deletions
2
cli/js/lib.deno.ns.d.ts
vendored
2
cli/js/lib.deno.ns.d.ts
vendored
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue