Function in thread compiler

unlock

fn unlock(Mutex m) -> Result<unit, ThreadError>
Import
use thread::{unlock};
Source: compiler/src/builtin_docs/thread.hy

Releases a mutex this thread locked with lock or try_lock.

Returns Err(ThreadError::Other) if this thread does not hold m.

Parameters#

NameType
mMutex

Returns#

Result<unit, ThreadError>

Examples#

use thread::{mutex, lock, unlock, ThreadError};
use tests::assert;
let m = match mutex(0) {
    Result::Ok(m) => m,
    Result::Err(_) => panic "mutex failed",
};
let _ = lock(m);
assert!(match unlock(m) { Result::Ok(_) => true, Result::Err(_) => false });
let not_held = match unlock(m) {
    Result::Err(ThreadError::Other) => true,
    default => false,
};
assert!(not_held);

See also#

  • thread::lock
  • thread::try_lock
  • spawn: Runs f(arg) on another OS thread and returns a handle to it.
  • join: Waits for the thread to finish and returns the value its function returned.
  • detach: Lets the thread run to completion without being joined.
  • channel: Creates an unbounded channel and returns its (Sender, Receiver) ends.
  • send: Sends a copy of value on the channel.
  • recv: Takes the next value from the channel, waiting until one arrives.
↑ ↓ navigate ↵ open