Code Monkey home page Code Monkey logo

rb's Introduction

rb

Build Status Build Status (appveyor) license rustdoc dependency status

A thread-safe fixed size circular (ring) buffer written in safe Rust.

Features

  • thread-safe
  • blocking and non-blocking IO
  • no unsafe blocks
  • never under- or overflows

Examples

cargo run --example saw

Benchmark

The benchmarking feature needs rust nightly.

rustup run nightly -- cargo bench

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

rb's People

Contributors

aschey avatar klingtnet avatar michaelbeaumont avatar mkpankov avatar nicolasklenert avatar willstott101 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar

rb's Issues

Panic when calling SpscRb::count()

The following code panics after running for a while, because SpscRb::slots_free() returns a number bigger than SpscRb::capacity():

fn test_threads_count_underflow() {
    const SIZE: usize = 1024*8;
    const WRITE_BUF_SIZE: usize = 100;
    const READ_BUF_SIZE: usize = 2048;
    const ITERATIONS: usize = 1000000;
    let rb = SpscRb::new(SIZE);
    let producer = rb.producer();
    let consumer = rb.consumer();
    let in_data = [0; WRITE_BUF_SIZE];

    thread::spawn(move || for _ in 0..ITERATIONS {
        producer.write_blocking(&in_data).unwrap();
        thread::sleep(time::Duration::from_millis(12));
    });

    for _ in 0..ITERATIONS {
        let mut buf = [0; READ_BUF_SIZE];
        if rb.count() < READ_BUF_SIZE {
            continue;
        } else {
            consumer.skip(rb.count() - READ_BUF_SIZE).unwrap();
            consumer.get(&mut buf).unwrap();
        }
    }
}

This is the panic message:

---- test_threads_count_underflow stdout ----
	thread 'test_threads_count_underflow' panicked at 'attempt to subtract with overflow', rb/src/lib.rs:243:9

Licensing

At the moment rb is licensed under GPLv3 but this is subject of change until there is a 1.0 release. If you've any concerns about using the GPL license, please leave a comment in this issue.

I still have to learn the differences between the all the major open-source software licenses. Luckily there is tldrlegal.com which helps a lot for this task.

Follow most recent Rust edition

This library was written before there were any Rust editions and in the meantime we have reached Rust 2021. With each Rust edition some defaults and best practices have changed. The rust docs should be a good place to start getting an overview of the changes.

Update the code to follow best practices of the latest Rust edition, that is Rust 2021.

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.