Skip to content

Commit 2d59985

Browse files
author
Stjepan Glavina
committed
Update
1 parent 463ae0e commit 2d59985

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ authors = ["Stjepan Glavina <[email protected]>"]
55
edition = "2018"
66
description = "Concurrent multi-producer multi-consumer queue"
77
license = "Apache-2.0 OR MIT"
8-
repository = "https://github.com/stjepang/async-mutex"
9-
homepage = "https://github.com/stjepang/async-mutex"
10-
documentation = "https://docs.rs/async-mutex"
8+
repository = "https://github.com/stjepang/concurrent-queue"
9+
homepage = "https://github.com/stjepang/concurrent-queue"
10+
documentation = "https://docs.rs/concurrent-queue"
1111
keywords = ["channel", "mpmc", "spsc", "spmc", "mpsc"]
1212
categories = ["concurrency"]
1313
readme = "README.md"

README.md

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
1-
# async-mutex
1+
# concurrent-queue
22

3-
[![Build](https://github.com/stjepang/async-mutex/workflows/Build%20and%20test/badge.svg)](
4-
https://github.com/stjepang/async-mutex/actions)
3+
[![Build](https://github.com/stjepang/concurrent-queue/workflows/Build%20and%20test/badge.svg)](
4+
https://github.com/stjepang/concurrent-queue/actions)
55
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](
6-
https://github.com/stjepang/async-mutex)
7-
[![Cargo](https://img.shields.io/crates/v/async-mutex.svg)](
8-
https://crates.io/crates/async-mutex)
9-
[![Documentation](https://docs.rs/async-mutex/badge.svg)](
10-
https://docs.rs/async-mutex)
6+
https://github.com/stjepang/concurrent-queue)
7+
[![Cargo](https://img.shields.io/crates/v/concurrent-queue.svg)](
8+
https://crates.io/crates/concurrent-queue)
9+
[![Documentation](https://docs.rs/concurrent-queue/badge.svg)](
10+
https://docs.rs/concurrent-queue)
1111

12-
An async mutex.
12+
A concurrent multi-producer multi-consumer queue.
1313

14-
The locking mechanism uses eventual fairness to ensure locking will be fair on average without
15-
sacrificing performance. This is done by forcing a fair lock whenever a lock operation is
16-
starved for longer than 0.5 milliseconds.
14+
There are two kinds of queues:
15+
16+
1. Bounded queue with limited capacity.
17+
2. Unbounded queue with unlimited capacity.
18+
19+
Queues also have the capability to get closed at any point. When closed, no more items can be
20+
pushed into the queue, although the remaining items can still be popped.
21+
22+
These features make it easy to build channels similar to `std::sync::mpsc` on top of this
23+
crate.
1724

1825
## Examples
1926

2027
```rust
21-
use async_mutex::Mutex;
22-
use smol::Task;
23-
use std::sync::Arc;
24-
25-
let m = Arc::new(Mutex::new(0));
26-
let mut tasks = vec![];
27-
28-
for _ in 0..10 {
29-
let m = m.clone();
30-
tasks.push(Task::spawn(async move {
31-
*m.lock().await += 1;
32-
}));
33-
}
34-
35-
for t in tasks {
36-
t.await;
37-
}
38-
assert_eq!(*m.lock().await, 10);
28+
use concurrent_queue::ConcurrentQueue;
29+
30+
let q = ConcurrentQueue::unbounded();
31+
q.push(1).unwrap();
32+
q.push(2).unwrap();
33+
34+
assert_eq!(q.pop(), Ok(1));
35+
assert_eq!(q.pop(), Ok(2));
3936
```
4037

4138
## License

0 commit comments

Comments
 (0)