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::set_process_name;
pub use hadean::spawn;
pub use hadean::spawn_in_locus;
pub use hadean::stop;
pub use machine::Machine;
pub use program::Program;
pub use hadean::trace_id;
pub use hadean::traced_spawn;
pub use hadean::traced_spawn_in_locus;

Modules

This module provides typed and untyped channels.

Contains the building blocks of any Hadean application.

Contains an API that can be used to control process scheduling.

Provides access to the prometheus crate and metrics related operations.

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

Contains builders to create programs and modify the environment they are run in.

This module provides access to the Platform’s tracing feature.

Enums