blocking
fn blocking<T>(unit -> T work) -> Result<T, ThreadError> Import
Source: use task::{blocking}; compiler/src/prelude/task.hy Runs work on another OS thread and waits for its result; only the current task waits, the others keep running.
Use it for CPU-heavy work or a blocking native call inside a scope. work
follows thread::spawn’s rules: it cannot capture locals.
Parameters#
| Name | Type |
|---|---|
work | unit -> T |
Returns#
Result<T, ThreadError>
Errors#
The ThreadError from starting or joining the thread.
See also#
task::scopethread::spawnsleep: 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.shield: Runsbodyso that a cancel waits for it to finish instead of interrupting it.channel: Creates a channel that holds up tocapacityvalues.blocking_with: Likeblocking, passingargtowork(it is copied to the other thread, likethread::spawn(work, arg)).