Class in thread compiler

Thread

class Thread
Import
use thread::{Thread};
Source: compiler/src/builtin_docs/thread.hy

A handle to a function running on another OS thread, from spawn.

Pass it to join to wait for the result, or to detach to let the thread finish on its own. A Thread cannot be sent to another thread.

Examples#

use thread::{spawn, join, Thread};
use tests::assert;
fn double(int n) -> int {
    return n * 2;
}

fn main() {
    let t: Thread = match spawn(double, 21) {
        Result::Ok(t) => t,
        Result::Err(_) => panic "spawn failed",
    };
    let n = match join(t) {
        Result::Ok(n) => n,
        Result::Err(_) => 0,
    };
    assert!(n == 42);
}

See also#

↑ ↓ navigate ↵ open