Skip to main content

ShutdownAsyncTasks

Function ShutdownAsyncTasks 

Source
pub unsafe extern "C" fn ShutdownAsyncTasks(cx: *mut JSContext)
Expand description

Cancel all cancellable async tasks and block until non-cancellable tasks are finished.

This will fire JSAsyncTaskFinished callbacks for all tasks, and there should be no outstanding tasks after this returns. All roots held by tasks will be released.

Destroying a JSRuntime will implicitly perform this. However, this is not soon enough for cycle collection, which needs to have roots dropped earlier so that the cycle collector can transitively remove roots for a future GC. For these and other cases, the set of pending async tasks can be canceled with this call earlier than JSRuntime destruction.