From 2cf4aebe7acdf7ef21dd1b56e8df40a439cc3296 Mon Sep 17 00:00:00 2001 From: Ruihan Li Date: Sun, 19 Jan 2025 08:45:04 +0900 Subject: [PATCH] Use `FnOnce() + Send` as task `func` --- kernel/src/thread/kernel_thread.rs | 4 ++-- ostd/src/task/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/src/thread/kernel_thread.rs b/kernel/src/thread/kernel_thread.rs index 9bfb67b0..6ce3f1bb 100644 --- a/kernel/src/thread/kernel_thread.rs +++ b/kernel/src/thread/kernel_thread.rs @@ -13,7 +13,7 @@ struct KernelThread; /// Options to create or spawn a new kernel thread. pub struct ThreadOptions { - func: Option>, + func: Option>, priority: Priority, cpu_affinity: CpuSet, } @@ -22,7 +22,7 @@ impl ThreadOptions { /// Creates the thread options with the thread function. pub fn new(func: F) -> Self where - F: Fn() + Send + Sync + 'static, + F: FnOnce() + Send + 'static, { let cpu_affinity = CpuSet::new_full(); Self { diff --git a/ostd/src/task/mod.rs b/ostd/src/task/mod.rs index 5a850b0c..b4fd32e2 100644 --- a/ostd/src/task/mod.rs +++ b/ostd/src/task/mod.rs @@ -149,7 +149,7 @@ impl TaskOptions { /// Creates a set of options for a task. pub fn new(func: F) -> Self where - F: FnOnce() + Send + Sync + 'static, + F: FnOnce() + Send + 'static, { Self { func: Some(Box::new(func)),