Fast multi-producer, multi-consumer unbounded channel with async support.

Overview

Hyperbridge

Fast multi-producer, multi-consumer unbounded channel with async support. Inspired by crossbeam unbounded channel.

Cargo Documentation License

Examples

Hyperbridge::channel: mpsc

use hyperbridge::channel;
use std::thread;

let (sender, receiver) = hyperbridge::channel::new();
let mut counter = 0;
let threads = 10;
let values = 10000;

let mut handles = vec![];

for i in 0..threads {
    let ch = sender.clone();
    let jh = thread::spawn(move || {
        for _ in 0..values {
            ch.send(i).unwrap();
        }
    });
    handles.push(jh);
}

let mut iters = threads * values;

while iters > 0 {
    match receiver.try_recv() {
        Ok(Some(v)) => {
            counter += v as usize;
            iters -= 1;
        }
        _ => {}
    }
}

let total = (0..threads).map(|i| i * values).sum();

for jh in handles.drain(..) {
    let _ = jh.join();
}

Hyperbridge::channel: mpmc

use hyperbridge::channel;
use std::thread;

const VALUES: usize = 10000;
const THREADS: usize = 16;

let (sender, receiver) = channel::new();
let counter = Arc::new(AtomicUsize::new(0));

let mut handles = vec![];

for i in 0..THREADS {
    let ch = sender.clone();
    let jh = thread::spawn(move || {
        for _ in 0..VALUES {
            ch.send(i).unwrap();
        }
    });
    handles.push(jh);
}

for _ in 0..THREADS {
    let ch = receiver.clone();
    let local_counter = counter.clone();
    let jh = thread::spawn(move || {
        let mut iters = VALUES;
        while iters > 0 {
            if let Ok(Some(v)) = ch.try_recv() {
                local_counter.fetch_add(v as usize, Relaxed);
                iters -= 1;
            }
        }
    });
    handles.push(jh);
}

for jh in handles.drain(..) {
    let _ = jh.join();
}

let total = (0..THREADS).map(|i| i * VALUES).sum();

Dependencies

# Cargo.toml
[dependencies]
hyperbridge = "0.1.0"

Feature with-futures

Turns on support for futures Sink, Stream:

# Cargo.toml
[dependencies]
hyperbridge = { version = "0.1.0", features = ["with-futures"] }

License

MIT/Apache-2.0

You might also like...
command line tools for coprolite research (paleontology and archaeology): estimate the producer's body mass based on coprolite diameter by the use of regression models
command line tools for coprolite research (paleontology and archaeology): estimate the producer's body mass based on coprolite diameter by the use of regression models

OVERVIEW OF COPROSIZE coprosize employs power, exponential and cubic regression models allowing to estimate the producer's body mass based on coprolit

Multi-channel signed distance field (MSDF) generator for fonts implemented in pure Rust.

msdfont WIP - school started so less updates from now on :(( Multi-channel signed distance field (MSDF) generator for fonts implemented in pure Rust.

Unlock vGPU functionality for consumer grade GPUs

Rust-based vgpu_unlock Unlock vGPU functionality for consumer-grade NVIDIA GPUs. This tool is to be used with the kernel patches from the main vgpu_un

Twitch data consumer and broadcaster

NeoTwitch Arch Network broadcaster Chat (message buffer) If the message buffer is full then shut down Channel point events If the message buffer is fu

A customizable, simple and easy to use json REST API consumer

JACK is a generic JSON API client. It is useful to interact with APIs from multiple services such as Google and Twitter

Zinnia is a runtime for Filecoin Station modules. It provides a sandboxed environment to execute untrusted code on consumer-grade computers.
Zinnia is a runtime for Filecoin Station modules. It provides a sandboxed environment to execute untrusted code on consumer-grade computers.

🌼 Zinnia Zinnia is a runtime for Filecoin Station modules. It provides a sandboxed environment to execute untrusted code on consumer-grade computers.

Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async
Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async

CDRS CDRS is looking for maintainers CDRS is Apache Cassandra driver written in pure Rust. 💡 Looking for an async version? async-std https://github.c

📺 Netflix in Rust/ React-TS/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Kafka, Redis, Tokio, Actix, Elasticsearch, Influxdb Iox, Tensorflow, AWS
📺 Netflix in Rust/ React-TS/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Kafka, Redis, Tokio, Actix, Elasticsearch, Influxdb Iox, Tensorflow, AWS

Fullstack Movie Streaming Platform 📺 Netflix in RUST/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Spark, Kafka, Redis,

A minimal readline with multiline and async support
A minimal readline with multiline and async support

RustyLine Async A minimal readline with multiline and async support. Inspired by rustyline , async-readline & termion-async-input.

Cross-platform pseudoterminal (PTY/ConPTY) implementation with async support

pseudoterminal The pseudoterminal crate is a versatile pseudoterminal (PTY) implementation designed for Rust, offering asynchronous capabilities. This

All in one (aka Aio) database with async support
All in one (aka Aio) database with async support

All in one (aka Aio) database with async support. Based on libsql/Sqlite, bevy_reflect and tokio, includes a dead simple API to be used (no SQL needed just pure Rust). Comes with automigration.

Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust

Error context library with support for type-erased sources and backtraces, targeting full support of all features on stable Rust, and with an eye towards serializing runtime errors using serde.

Shared Channel for WebAssembly

Shared Channel for WebAssembly This crate provides a way for WebAssembly threads to receive messages from other threads using a JavaScript primitive c

A small discord bot to archive the messages in a discord text channel.

discord-channel-archiver A small discord bot to archive the messages in a discord text channel. This is still WIP. The HTML and JSON modes are vaguely

A client-side gRPC channel implementation for tonic

ginepro ginepro provides client-side gRPC load-balancing out of the box by enriching tonic ‘s channel with periodic service discovery. Overview ginepr

Fuzzer to automatically find side-channel (timing) vulnerabilities
Fuzzer to automatically find side-channel (timing) vulnerabilities

SideFuzz: Fuzzing for side-channel vulnerabilities SideFuzz is an adaptive fuzzer that uses a genetic-algorithm optimizer in combination with t-statis

Source code for the Telegram channel @pixiv_daily
Source code for the Telegram channel @pixiv_daily

PixivDaily (Rust) This repository contains the source code of the program running the Telegram channel @pixiv_daily. Usage First, you'll need to clone

musify is a simple discord bot to play music within a voice channel, written in the rust programming language.

musify-rs musify is a simple discord bot to play music within a voice channel, written in the rust programming language. Features A simple song queue

A library for easily creating WebRTC data channel connections in Rust

Cyberdeck A library for easily creating WebRTC data channel connections in Rust.

Robyn is an async Python backend server with a runtime written in Rust, btw.

Robyn is an async Python backend server with a runtime written in Rust, btw.

Sanskar Jethi 1.8k Jan 4, 2023
A lock-free multi-producer multi-consumer unbounded queue.

lf-queue A lock-free multi-producer multi-consumer unbounded queue. Examples [dependencies] lf-queue = "0.1" Single Producer - Single Consumer: use lf

Pierre Brouca 2 Sep 11, 2022
A safe sync/async multi-producer, multi-consumer channel

Loole A safe async/sync multi-producer multi-consumer channel. Producers can send and consumers can receive messages asynchronously or synchronously:

Mahdi Shojaee 50 Oct 6, 2023
Handoff is an unbuffered, single-producer / single-consumer, async channel

handoff handoff is a single-producer / single-consumer, unbuffered, asynchronous channel. It's intended for cases where you want blocking communicatio

Nathan West 7 Feb 7, 2023
An asynchronous, multi-producer, single-consumer (MPSC) bounded channel that operates at tachyonic speeds

tachyonix An asynchronous, multi-producer, single-consumer (MPSC) bounded channel that operates at tachyonic speeds. This library is an offshoot of As

Asynchronics 66 Jan 29, 2023
A Rust on-site channel benchmarking helper. Inter-Process (async / busy) & Intra-Process (async single threaded / async multi threaded)

On-Site Rust Channel Benchmarking Helper Deploy on server to determine which public crates are the fastest for communicating in different architecture

null 23 Jul 9, 2024
A single-producer single-consumer Rust queue with smart batching

Batching Queue A library that implements smart batching between a producer and a consumer. In other words, a single-producer single-consumer queue tha

Roland Kuhn 2 Dec 21, 2021
A balanced unbounded interval-tree in Rust with associated values in the nodes

store-interval-tree A balanced unbounded interval-tree in Rust with associated values in the nodes. Based on rudac and bio. Example use store_interval

Andrea Fioraldi 3 Nov 22, 2022
The feature-rich, portable async channel library

The feature-rich, portable async channel library > crates.io > docs.rs Why use Postage? Includes a rich set of channels. | barrier | broadcast | dispa

Austin Jones 221 Dec 26, 2022
All-batteries included GStreamer WebRTC producer

webrtcsink All-batteries included GStreamer WebRTC producer, that tries its best to do The Right Thing™. Use case The webrtcbin element in GStreamer i

Centricular 75 Dec 14, 2022