//= { //= "output": { //= "2": [ //= "", //= true //= ], //= "1": [ //= "1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n1234567890\n", //= true //= ] //= }, //= "children": [ //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= }, //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= }, //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= }, //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= }, //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= }, //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= }, //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= }, //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= }, //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= }, //= { //= "output": { //= "1": [ //= "hi\n", //= true //= ], //= "2": [ //= "", //= true //= ] //= }, //= "children": [], //= "exit": "Success" //= } //= ], //= "exit": "Success" //= } use constellation::*; fn main() { init(Resources { mem: 20 * Mem::MIB, ..Resources::default() }); futures::executor::block_on(async { let pids = (0..10) .map(|_| { spawn( Resources { mem: 20 * Mem::MIB, ..Resources::default() }, FnOnce!(|parent| { futures::executor::block_on(async { let receiver = Receiver::::new(parent); let sender = Sender::::new(parent); println!("{}", receiver.recv().await.unwrap()); sender.send(1_234_567_890).await; }) }), ) .block() .expect("spawn() failed to allocate process") }) .collect::>(); let channels = pids .into_iter() .map(|pid| (Sender::::new(pid), Receiver::::new(pid))) .collect::>(); for &(ref sender, ref _receiver) in channels.iter() { sender.send(String::from("hi")).await; } for &(ref _sender, ref receiver) in channels.iter() { println!("{}", receiver.recv().await.unwrap()); } }) }