Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.
/ ssq Public archive

A #[no_std], single-producer, single-consumer, single-slot queue, useful for thread-safe message passing in embedded systems.

License

Notifications You must be signed in to change notification settings

jbeaurivage/ssq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A #[no_std], single-producer, single-consumer, single-slot queue, useful for thread-safe message passing in embedded systems.

Example

use ssq::{Producer, Consumer, SingleSlotQueue};
let mut queue = SingleSlotQueue::<u32>::new();
let (mut cons, mut prod) = queue.split();

// `enqueue` returns `None` when the queue is empty.
let maybe_returned = prod.enqueue(50);
assert!(maybe_returned == None);

// `enqueue` returns `Some(t)` when the queue is already full.
let maybe_returned = prod.enqueue(2);
assert!(maybe_returned == Some(2));

// `enqueue_overwrite` overwrites the old value, at the cost of taking a lock.
prod.enqueue_overwrite(25);
assert!(cons.dequeue() ==  Some(25));

// `dequeue` returns `None` if the queue is empty.
assert!(cons.dequeue() == None);

About

A #[no_std], single-producer, single-consumer, single-slot queue, useful for thread-safe message passing in embedded systems.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages