1 个不稳定版本
使用旧的 Rust 2015
| 0.1.0 | 2016年9月10日 | 
|---|
#86 在 #push
6KB
151 行
原始动力:为 x86_64 实现无锁栈
lib.rs:
为 x86_64 实现的无锁栈。提供基本的线程安全栈操作。
示例
use concurrent_stack::ConcurrentStack;
use std::sync::Arc;
use std::thread;
let stack = Arc::new(ConcurrentStack::new());
let pusher = stack.clone();
let producer = thread::spawn(move || {
    for i in 0..100 {
        pusher.push(i);
    }
});
let poper = stack.clone();
let consumer = thread::spawn(move || {
    for _ in 0..100 {
        if let Some(v) = poper.pop() {
            // Deal with v.
        }
    }   
});
producer.join();
consumer.join();
依赖项
~10KB