Use CpuId with validity ensurance rather than u32

This commit is contained in:
Zhang Junyang
2024-09-23 11:51:53 +08:00
committed by Tate, Hongliang Tian
parent b400d287fa
commit 3468ec213b
20 changed files with 160 additions and 107 deletions

View File

@ -64,7 +64,7 @@
//!
//! ```
use ostd::cpu::CpuSet;
use ostd::cpu::{CpuId, CpuSet};
use spin::Once;
use work_item::WorkItem;
use worker_pool::WorkerPool;
@ -150,7 +150,7 @@ impl WorkQueue {
/// Request a pending work item. The `request_cpu` indicates the CPU where
/// the calling worker is located.
fn dequeue(&self, request_cpu: u32) -> Option<Arc<WorkItem>> {
fn dequeue(&self, request_cpu: CpuId) -> Option<Arc<WorkItem>> {
let mut inner = self.inner.disable_irq().lock();
let index = inner
.pending_work_items
@ -160,7 +160,7 @@ impl WorkQueue {
Some(item)
}
fn has_pending_work_items(&self, request_cpu: u32) -> bool {
fn has_pending_work_items(&self, request_cpu: CpuId) -> bool {
self.inner
.disable_irq()
.lock()