https://github.com/cppcoffee/stack-rs
lock-free linked stack.
https://github.com/cppcoffee/stack-rs
Last synced: 8 months ago
JSON representation
lock-free linked stack.
- Host: GitHub
- URL: https://github.com/cppcoffee/stack-rs
- Owner: cppcoffee
- Created: 2021-04-05T09:19:55.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-04T11:36:40.000Z (almost 5 years ago)
- Last Synced: 2025-03-23T18:34:25.798Z (about 1 year ago)
- Language: Rust
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## stack-rs
stack-rs is a free-lock library implemented using rust.
### quick start
```rust
let s = Stack::new();
s.push(1);
assert_eq!(s.pop(), Some(1));
assert_eq!(s.pop(), None);
```
### benchmark
Lock-Free Stack VS std::sync::Mutex\
main.rs benchmark output:
| Benchmark | Total time spent | Average time spent |
| ------------- | ----- | ------- |
| stack_loop_n(100000) | 56.523467ms | 565ns |
| list_loop_n(100000) | 67.573497ms | 675ns |
| stack_thread_n_m(2, 100000) | 115.590207ms | 577ns |
| list_thread_n_m(2, 100000) | 161.359683ms | 806ns |
| stack_thread_n_m(4, 100000) | 440.585874ms | 1.101µs |
| list_thread_n_m(4, 100000) | 562.439723ms | 1.406µs |
| stack_thread_n_m(8, 100000) | 1.886768172s | 2.358µs |
| list_thread_n_m(8, 100000) | 2.120945074s | 2.651µs |
### reference
[Implementing Lock-Free Queues (1994)](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.53.8674)