shield
fn shield<T>(unit -> T body) -> T Import
Source: use task::{shield}; compiler/src/prelude/task.hy Runs body so that a cancel waits for it to finish instead of interrupting it.
Use it around work that must not be left half done, such as writing a
record. A cancel that arrives meanwhile takes effect when body returns.
Parameters#
| Name | Type |
|---|---|
body | unit -> T |
Returns#
T
See also#
scope: Runsbodywith aScopefor starting child tasks, and returns its value oncebodyand every child have finished.sleep: Suspends the current task for at leastmsmilliseconds; other tasks run meanwhile.yield_now: Lets other ready tasks run before the current one continues.timeout: Runsbodyas a task and cancels it if it has not finished aftermsmilliseconds.channel: Creates a channel that holds up tocapacityvalues.blocking: Runsworkon another OS thread and waits for its result; only the current task waits, the others keep running.blocking_with: Likeblocking, passingargtowork(it is copied to the other thread, likethread::spawn(work, arg)).block_on: Resumes the coroutinehandleuntil it is done and returns its completion value; values it yields are discarded.