pub fn current_token() -> Option<CancelToken>Expand description
Token of the request or task currently executing on this thread.
Inside a host function called from Lua code that an isle runs, this
is the token of that request (for coroutine requests and tasks, the
one being polled). Use it to derive a child_token
for work the host function starts, so that cancelling the request
reaches that work too. Returns None outside such a context.
Work started this way (a spawn_local of its own) is cancelled with
the request, but the request neither waits for it nor drops it. To
have the request wait for the work (and drop it when the grace ends),
spawn it through the request’s scope with
runtime::current_scope() and ScopeHandle::spawn_local (tokio
feature), or do it inside the future of a
create_async_function, so the
coroutine awaits it.