CSPLib is an implementation of Communicating Sequential Processes (CSP), a way of implementing “one shot” concurrent applications. With this library, you can implement applications like logic circuit or computational graph.
The core of the library is SPMC channel for message passing but for ease of use, this library provides code generating procedural macro. The following struct definition generates boilerplates
#[csplib::process]
struct And {
#[input]
a: bool,
#[input]
b: bool,
#[output]
c: bool,
}
and user can focus on the implementation of the process logic.
async fn run_and(inner: AndInner) -> Result<()> {
let a = inner.a.reader();
let b = inner.b.reader();
let (a, b) = tokio::try_join!(a.get(), b.get())?;
let c = a & b;
inner.c.put(c)?;
Ok(())
}
If you like this library, please use in your projects. Thank you.