Crate orphan_crippler

source ·
👎Deprecated: use crossbeam_channel instead
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.

Example

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;
    sender.send::<i32>(result);
});

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

Features

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.

Structs

  • ReceiverDeprecated
    The receiver for the two-way oneshot channel. It is consumed upon receiving its data.
  • SenderDeprecated
    The sender for the two-way oneshot channel. It is consumed upon sending its data.

Functions

  • completeDeprecated
    Creates a receiver that automatically resolves.
  • complete_boxedDeprecated
    Equivalent to complete, but uses a boxed R to avoid a layer of indirection, if you already have one of those.
  • twoDeprecated
    Creates a sender and a receiver for the two-way oneshot (two) channel.