1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
//! # 提供了异步运行时需要的队列和锁 //! use std::hint::spin_loop; pub mod spin_lock; /// /// 根据指定值进行自旋,返回下次自旋的值 /// #[inline] pub fn spin(mut len: u32) -> u32 { if len < 1 { len = 1; } else if len > 10 { len = 10; } for _ in 0..(1 << len) { spin_loop() } len + 1 }