mrsc 0.3.1

mpsc with requests
Documentation
  • Coverage
  • 65.22%
    15 out of 23 items documented8 out of 19 items with examples
  • Size
  • Source code size: 12.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.88 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • kpcyrd/mrsc
    4 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kpcyrd

mrsc Build Status Crates.io

mpsc with requests. This is a basic building block based on rusts mpsc if you have multiple workers that need to execute transactions on a shared state, without having to share your state struct across all threads. Beware that transactions are blocking, so it's recommended to avoid expensive code in the transaction handler.

Installation

Add this to your Cargo.toml dependency list:

[dependencies]
mrsc = "0.3"

Add this to your crate root:

extern crate msrc

Example

use mrsc;
use std::thread;

let server: mrsc::Server<u32, String> = mrsc::Server::new();
let channel = server.pop();

thread::spawn(move || {
    let req = server.recv().unwrap();
    let reply = {
        let msg = req.get();
        println!("request: {:?}", msg);

        "hello world".to_string()
    };
    req.reply(reply).unwrap();
});

let response = channel.req(123).unwrap();
let reply = response.recv().unwrap();
println!("response: {:?}", reply);

License

MIT