Giter Club home page Giter Club logo

uchan's Introduction

μchan

Small, scalable, unbounded, mpsc channel.

Cargo Documentation License

This is (almost) a drop-in replacement for std::sync::mpsc with a focus on being lock-free and scalable for both producers and consumers. It also supports being used as #![no_std], in which the caller provides a trait used to block and unblock a thread, with the queue implementing everything else from there.

Usage

[dependencies]
uchan = "0.1.4"

Benchmarking

cd benchmark
cargo run --release

For adding custom channels to the benchmark, see benchmark/src/queues.rs.

License

uchan is licensed under MIT (http://opensource.org/licenses/MIT)

uchan's People

Contributors

kprotty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

icodein

uchan's Issues

Adding a few channels to bench

I did see the note in the README about where to add them, however, I don't know enough about macros to add in these implementations where the imports look different.

If you have time or interest, could you consider adding these please:

https://docs.rs/tokio/latest/tokio/sync/oneshot/index.html

use tokio::sync::oneshot;

#[tokio::main]
async fn main() {
    let (tx, rx) = oneshot::channel();

https://docs.rs/tokio/latest/tokio/sync/mpsc/fn.channel.html

use tokio::sync::mpsc;

#[tokio::main]
async fn main() {
    let (tx, mut rx) = mpsc::channel(100);

https://docs.rs/futures-channel/latest/futures_channel/oneshot/fn.channel.html

use futures::channel::oneshot;
use std::{thread, time::Duration};

let (sender, receiver) = oneshot::channel::<i32>();

Ones without examples:
https://docs.rs/tokio/latest/tokio/sync/mpsc/fn.unbounded_channel.html
https://docs.rs/futures-channel/latest/futures_channel/mpsc/fn.channel.html
https://docs.rs/futures-channel/latest/futures_channel/mpsc/fn.unbounded.html

Also a few questions:
Is there such a thing as spmc?
What optimizations are possible for this use case... things that spmc in particular can take advantage of.

slice length without minus offset?

fn slice<S>(&self, offset: usize) -> &[S] {
        unsafe {
            let ptr = self.ptr.add(offset).cast();
            slice::from_raw_parts(ptr, self.capacity) 
        }
    }

should slice::from_raw_parts(ptr, self.capacity) be updated to slice::from_raw_parts(ptr, self.capacity-offset)?
and also offset need check range, otherwise it might have buffer overflow?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.