Crate orphan_crippler[][src]

Expand description

This crate provides an abstraction for outsourcing a piece of work to another thread. This is a common pattern in not only async programs, but OS-specific programs where it is expected that a certain piece of work is done on a certain thread. To accomplish this, the crate provides a Two, short for “Two Way Oneshot” (not a recursive acronym). It is implemented as a sender and a receiver, similar to other channels in the Rust ecosystem. The primary difference is that the sender comes bundled with a data type of your choice, and that the sender and receiver are both consumed upon data transmission.


Creates a thread that processes the work of squaring a number.

use orphan_crippler::two;
use std::thread;

let (mut sender, receiver) = two::<i32, i32>(5);

thread::spawn(move || {
    let input = sender.input().unwrap();
    let result = input * input;

assert_eq!(receiver.recv(), 25);


If the parking_lot feature is enabled, this crate uses mutexes from the parking_lot crate internally, rather than std::sync mutexes. This is recommended if you are using parking_lot mutexes elsewhere in your application.



The receiver for the two-way oneshot channel. It is consumed upon receiving its data.


The sender for the two-way oneshot channel. It is consumed upon sending its data.



Creates a receiver that automatically resolves.


Equivalent to complete, but uses a boxed R to avoid a layer of indirection, if you already have one of those.


Creates a sender and a receiver for the two-way oneshot (two) channel.