1 个不稳定版本
0.2.0 | 2024年1月10日 |
---|---|
0.1.0 |
|
#10 在 #无界
28KB
462 行
pin-queue
一个不需要动态内存分配的无界队列。
示例
use pin_queue::mutex::CriticalSectionMutex;
use pin_queue::Deque;
use core::pin::pin;
// Create a new queue of `u32`, using the `CriticalSectionMutex` mutex.
let queue = Deque::<CriticalSectionMutex, u32>::new(CriticalSectionMutex::new());
{
// Create a node, and pin it to the stack.
let mut node = pin!(queue.new_node(1));
// Push the node onto the queue.
queue.push_back(node.as_mut()).unwrap();
// Pop our node off the queue.
assert_eq!(queue.pop_front_copy().unwrap(), 1);
// Push our node back onto the queue.
queue.push_back(node.as_mut()).unwrap();
} // Node gets dropped and automatically removed from the queue
assert!(queue.is_empty());
许可协议
版权所有 2023 ThatRedox
根据 Apache License 2.0 版本(“许可协议”);除非遵守许可协议,否则不得使用此文件。您可以在以下位置获得许可协议的副本:
https://apache.ac.cn/licenses/LICENSE-2.0
除非适用法律要求或书面同意,否则在许可协议下分发的软件按“现状”基础分发,不提供任何明示或暗示的保证或条件。有关许可协议的具体语言、权限和限制,请参阅许可协议。
依赖项
~0–5MB