Git Product home page Git Product logo

blinkcast's Introduction

blinkcast

check codecov Crates.io blinkcast docs.rs blinkcast

Fast, Bounded, Lossy Rust broadcast channel with support for no_std targets.

Sometimes it may spin the CPU for a bit if there is a contention on a single element in the buffer for write and read operations. Could happen more often for small buffers.

This is implemented with ring buffer and atomic operations, it may be considered lock-free, as we don't use Lock premitive, but the implementation may spin waiting for a contending writer/reader to finish accessing a specific node. Its very rare, but maybe I won't call it lock-free in the strict sense.

The API of the blinkcast is similar to that of the std::sync::mpsc channels. However, there are some differences:

  • It allows for multiple consumers (receivers) and multiple producers (senders).
  • The channel broadcasts every send to every consumer.
  • Lossy, the sender will overwrite old data, so receivers must be quick or they will lose the old data (don' t blink).
  • Implemented for no_std environments.

Due to that nature, this is useful in applications where data comes in very quick and new data is always more important than old data which can be discarded. This could be useful for example in implementing:

  • audio driver (small glitch but staying up to date is better than delayed audio).
  • mouse/keyboard driver with big enough buffer (This was actually why this was created, see: Amjad50/Emerald#71 and Amjad50/Emerald#72)
  • etc...

See the documentation for examples.

Minimum Supported Rust Version (MSRV)

The minimum supported Rust version for this crate is 1.61.0

License

Licensed under MIT (LICENSE or http://opensource.org/licenses/MIT)

blinkcast's People

Contributors

amjad50 avatar

Watchers

 avatar

blinkcast's Issues

Drop as soon as no readers will read the value

The current behavior of the channel has a small issue for dropping behavior.

Currently, the values in the buffer will only be dropped when its overwritten, thus if the values used are expensive allocations
it will be helped by the channel until its overwritten by another value.

Would be nice to implement a smart behavior to drop the value as soon as the last possible reader reads it.

Maybe this could be implemented by keeping track of how many readers are possible at each node (keep track of number of readers?)

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.