Make atomic mode panics have clear messages

This commit is contained in:
Ruihan Li
2024-11-18 23:35:21 +08:00
committed by Tate, Hongliang Tian
parent 065a3bd1c3
commit 969ac97144
13 changed files with 31 additions and 0 deletions

View File

@ -73,6 +73,7 @@ impl ThreadOptions {
}
/// Builds a new kernel thread and runs it immediately.
#[track_caller]
pub fn spawn(self) -> Arc<Thread> {
let task = self.build();
let thread = task.as_thread().unwrap().clone();

View File

@ -78,6 +78,7 @@ impl Thread {
}
/// Runs this thread at once.
#[track_caller]
pub fn run(&self) {
self.status.store(ThreadStatus::Running, Ordering::Release);
self.task.upgrade().unwrap().run();
@ -151,6 +152,7 @@ impl Thread {
/// Yields the execution to another thread.
///
/// This method will return once the current thread is scheduled again.
#[track_caller]
pub fn yield_now() {
Task::yield_now()
}
@ -158,6 +160,7 @@ impl Thread {
/// Joins the execution of the thread.
///
/// This method will return after the thread exits.
#[track_caller]
pub fn join(&self) {
while !self.is_exited() {
Self::yield_now();