Enum in thread compiler

ThreadError

enum ThreadError
Import
use thread::{ThreadError};
Source: compiler/src/builtin_docs/thread.hy

The error of every thread function.

It implements Show, so format("%v", e) gives the variant name.

Variants#

WouldBlock#

The operation would have to wait: try_recv on an empty channel, or try_lock / try_read / try_write on a lock that is held.

Disconnected#

The channel is closed: send after close, or recv / try_recv on a closed channel with no values left.

JoinFailed#

The thread cannot be joined: it was already joined or detached, or it panicked instead of returning a value.

NotSendable#

A value cannot cross to another thread: it is or contains a stream, a Thread, a coroutine, a gc handle, a partially applied function, or a cycle.

Poisoned#

A readers-writer lock was poisoned by a thread that panicked while holding it.

Other#

Any other failure: an unlock of a mutex this thread does not hold, a second lock while one is held, or a lock callback that does not return a pair.

Examples#

use thread::{channel, close, send, ThreadError};
use tests::assert;
let (tx, rx) = match channel() {
    Result::Ok(pair) => pair,
    Result::Err(_) => panic "channel failed",
};
let _ = close(tx);
let closed = match send(tx, 1) {
    Result::Err(ThreadError::Disconnected) => true,
    default => false,
};
assert!(closed);

See also#

↑ ↓ navigate ↵ open