Function in task compiler

blocking

fn blocking<T>(unit -> T work) -> Result<T, ThreadError>
Import
use task::{blocking};
Source: 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#

NameType
workunit -> T

Returns#

Result<T, ThreadError>

Errors#

The ThreadError from starting or joining the thread.

See also#

  • task::scope
  • thread::spawn
  • sleep: Suspends the current task for at least ms milliseconds; other tasks run meanwhile.
  • yield_now: Lets other ready tasks run before the current one continues.
  • timeout: Runs body as a task and cancels it if it has not finished after ms milliseconds.
  • shield: Runs body so that a cancel waits for it to finish instead of interrupting it.
  • channel: Creates a channel that holds up to capacity values.
  • blocking_with: Like blocking, passing arg to work (it is copied to the other thread, like thread::spawn(work, arg)).
↑ ↓ navigate ↵ open