A Rust synchronisation primitive for "Multiplexed Concurrent Single-Threaded Read" access

Overview

exit-left

verb;

1. To exit or disappear in a quiet, non-dramatic fashion, making way for more interesting events.

2. (imperative) Leave the scene, and don't make a fuss.

A rust synchronization primitive that can allow multiplexing of an underlying resource.

The idea is as such; You have many threads, all of them want to "wait" for some event to come through the pipeline, but the pipeline can give all kinds events in any order.

Worse still, only one thread can poll/block on this resource, and could have to deal with the unwanted events before it gets the one it would want.

This crate's Stage struct is the solution, any thread "heading" it would be responsible for routing the events, but it would be provided the tools to easily alert other threads waiting for "it's own" resource.

It does this via a Hash + Eq token type, which is passed to a ticket function, registering the token to be activated. Following this, the thread can then investigate the buffer, if it finds nothing, it can enter the stage, after which it will resume under one of the following three conditions;

  1. The thread is promoted to "heading" the stage, this can happen after the previous heading stage exits the stage, or if this thread is the first one to "enter" it.
  2. The thread passes a timeout parameter, and it passes by, the thread will then resume.
  3. A "heading" thread will notify this thread via its token, the thread will then resume.

Usage

A potential usage would be to poll a UdpSocket, which can receive packets from multiple sources, but also send to multiple.

Unlike a TcpStream, a UdpSocket has two potential modes, "Connected", or "Not Connected".

The former merely meaning that a filter is in place for a particular source, and all other packets are dropped.

Thus, normally, a UdpSocket in only "Connected" states would have to be constructed again and again for every local-remote tuple it would be used for, with local ports becoming unaccessible to the rest of the system after its been bind-ed.

So, the Stage can help many threads to await a socket at the same time, while only one does the actual routing work, while still leaving the ability to notify threads waiting for "their" endpoint.

You might also like...
Provides filesystem access for the Rhai scripting language.

About rhai-fs This crate provides filesystem access for the Rhai scripting language. Usage Cargo.toml [dependencies] rhai-fs = "0.1.2" Rhai script //

A GPT-3 access point through Nostr, powered by lightning

Geppeto A Nostr based API for GPT-3, powered on Lightning. The bot listens for event kind 29000 (inspired by NIP-9000) and will query the prompt to th

Temporary elevated access management as a self-hosted service
Temporary elevated access management as a self-hosted service

💻🔐☁️ S A T O U N K I Temporary elevated access management as a self-hosted service Overview Satounki is a self-hosted service which brings visibilit

Rust-advent - Learning Rust by solving advent of code challenges (Streaming live on Twitch every Monday)
Rust-advent - Learning Rust by solving advent of code challenges (Streaming live on Twitch every Monday)

Rust advent 🦀 🐚 Learning Rust by implementing solutions for Advent of Code problems. 🎥 HEY, we are live-streaming our attempts to solve the exercis

Rust-clippy - A bunch of lints to catch common mistakes and improve your Rust code

Clippy A collection of lints to catch common mistakes and improve your Rust code. There are over 450 lints included in this crate! Lints are divided i

Rust-battery - Rust crate providing cross-platform information about the notebook batteries.

battery Rust crate providing cross-platform information about the notebook batteries. Table of contents Overview Supported platforms Install Examples

A Rust-based shell script to create a folder structure to use for a single class every semester. Mostly an excuse to use Rust.

A Rust Course Folder Shell Script PROJECT IN PROGRESS (Spring 2022) When completed, script will create a folder structure of the following schema: [ro

Rust Imaging Library's Python binding: A performant and high-level image processing library for Python written in Rust

ril-py Rust Imaging Library for Python: Python bindings for ril, a performant and high-level image processing library written in Rust. What's this? Th

FTL Rust Demangler is a command-line tool for demangling symbol names that are mangled with the Rust convention

FTL Rust Demangler is a command-line tool for demangling symbol names that are mangled with the Rust convention. It takes a mangled symbol name as input and returns the demangled name

Owner
Jonathan de Jong
amateur sysadmin, likes coffee with sugar and milk
Jonathan de Jong
zigfi is an open-source stocks, commodities and cryptocurrencies price monitoring CLI app, written fully in Rust, where you can organize assets you're watching easily into watchlists for easy access on your terminal.

zigfi zigfi is an open-source stocks, commodities and cryptocurrencies price monitoring CLI app, written fully in Rust, where you can organize assets

Aldrin Zigmund Cortez Velasco 18 Oct 24, 2022
Easy access of struct fields in strings using different/custom pre/postfix: "Hello, {field}" in rust

Easy access to struct fields in strings ?? add strung to the dependencies in the Cargo.toml: [dependencies] strung = "0.1.3" ?? use/import everything

Dekirisu 2 Sep 19, 2022
Pure rust library for reading / writing DNG files providing access to the raw data in a zero-copy friendly way.

DNG-rs   A pure rust library for reading / writing DNG files providing access to the raw data in a zero-copy friendly way. Also containing code for re

apertus° - open source cinema 4 Dec 1, 2022
🍥 Access the rust playground right in your terminal

rustycli — ?? Access the rust playground right in your terminal ?? rustycli is a tool, allowing you to access the rust playground right in the termina

Nabeen Tiwaree 29 Jul 31, 2023
A new pure-Rust library for cross-platform low-level access to USB devices.

nusb A new pure-Rust library for cross-platform low-level access to USB devices. Documentation Compared to rusb and libusb Pure Rust, no dependency on

Kevin Mehall 23 Oct 30, 2023
sg = Steam Guard, access sg verification code locally.

Steam Guard CLI Access your Steam Guard token locally. Credit https://github.com/steevp/UpdogFarmer/blob/master/app/src/main/java/com/steevsapps/idled

Vanilla's Lab 7 Nov 10, 2022
Gix is a command-line interface (CLI) to access git repositories

gix is a command-line interface (CLI) to access git repositories. It's written to optimize the user-experience, and perform as good or better than the

Sebastian Thiel 5.2k Jan 5, 2023
A truly zero-dependency crate providing quick, easy, reliable, and scalable access to the name "jordin"

jordin Finally! A truly zero-dependency crate providing quick, easy, reliable, and scalable access to the name "jordin". Additionally, this one-of-a-k

jordin 2 Aug 4, 2022
Low level access to processors using the AArch64 execution state.

aarch64-cpu Low level access to processors using the AArch64 execution state. Usage Please note that for using this crate's register definitions (as p

Rust Embedded 18 Jan 5, 2023
A library to provide abstractions to access common utilities when developing Dioxus applications.

?? Dioxus Standard Library ?? A platform agnostic library for supercharging your productivity with Dioxus. dioxus-std is a Dioxus standard library tha

Miles Murgaw 5 Nov 9, 2022