5 releases
0.0.0-pre-release3.1 | Jan 13, 2023 |
---|---|
0.0.0-pre-release3.0 | Jan 12, 2023 |
0.0.0-pre-release1.0 | Jan 11, 2023 |
#20 in #pop
22 downloads per month
15KB
384 lines
Unlink
lib.rs
:
This crate provides a lock free stack that supports concurrent push
, pop
, peek
, and
extend
.
use unlink::Stack;
use std::thread;
let stack = Stack::new();
thread::scope(|s| {
let stack = &stack;
s.spawn(move || {
for i in 0..100 {
stack.push(i);
}
});
s.spawn(move || {
for _ in 0..100 {
stack.pop();
}
});
s.spawn(move || {
for _ in 0..100 {
let _ = stack.peek();
}
});
s.spawn(move || {
for i in 0..10_usize {
stack.append(vec![i.pow(2), i.pow(3), i.pow(4)].into_iter().collect());
}
});
});
stack.into_iter().for_each(|v| print!("{}, ", v));
Dependencies
~0.1–25MB
~334K SLoC