Crate hadean[][src]

Expand description

The Hadean Platform SDK

Hello world!

use futures::prelude::*;
use tokio::runtime::Runtime;

use ::hadean::hadean;
use ::hadean::channel::{Receiver, Sender};

fn child() {
    println!("child start");
    Runtime::new().unwrap().block_on(async move {
        let (sender, receiver) = hadean::accept().await.unwrap();
        let (mut sender, mut receiver): (Sender<String>, Receiver<String>)
            = (sender.into(), receiver.into());
        sender.send(String::from("child")).await.unwrap();
        let message = receiver.next().await.unwrap().unwrap();
        println!("child received: {}", message);
    });
    println!("child end");
}

fn main() {
    hadean::init();
    println!("parent start");
    Runtime::new().unwrap().block_on(async move {
        let pid = hadean::spawn(child).await.expect("failed to spawn");
        let (sender, receiver) = hadean::connect(pid).await.unwrap();
        let (mut sender, mut receiver): (Sender<String>, Receiver<String>)
            = (sender.into(), receiver.into());
        sender.send(String::from("parent")).await.unwrap();
        let message = receiver.next().await.unwrap().unwrap();
        println!("parent received: {}", message);
    });
    println!("parent end");
}

Re-exports

pub use channel::Receiver;
pub use channel::Sender;
pub use hadean::Pid;
pub use hadean::accept;
pub use hadean::connect;
pub use hadean::init;
pub use hadean::spawn;

Modules

channel

This module provides typed and untyped channels.

hadean

Contains the building blocks of any Hadean application.

pool

Contains a process pool that can be used to build applications (optional).