mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-28 20:03:22 +00:00
Make atomic mode panics have clear messages
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
065a3bd1c3
commit
969ac97144
@ -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();
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user