1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#![no_std]
#![feature(allocator_api)]
#![feature(try_reserve)]
#![feature(box_into_pin)]
#![feature(const_panic)]
#![feature(associated_type_bounds)]
#![feature(shrink_to)]
#![feature(const_fn_trait_bound)]
#![feature(new_uninit)]
#![feature(maybe_uninit_extra)]
#[cfg(test)]
#[macro_use]
extern crate std;
extern crate alloc;
mod condvar;
mod mutex;
mod priority_queue;
mod rwlock;
mod sleep_queue;
mod waker;
pub mod executor;
pub mod mpsc;
pub mod task;
pub mod time;
pub mod sync {
pub use super::condvar::Condvar;
pub use super::mpsc;
pub use super::mutex::{Mutex, MutexGuard};
pub use super::rwlock::{RwLock, RwLockReadGuard, RwLockUpgradableReadGuard, RwLockWriteGuard};
pub use spin::lock_api::{Mutex as Spinlock, MutexGuard as SpinlockGuard};
}
#[cfg(test)]
pub mod tests {
use super::*;
pub fn run_multi(ncpu: usize) {
let mut threads = vec![];
for _ in 0..ncpu {
let t = std::thread::spawn(move || {
task::run();
});
threads.push(t);
}
for thread in threads {
thread.join().unwrap();
}
}
}