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

@ -32,6 +32,7 @@ pub trait Pause: WaitTimeout {
/// condition is met.
///
/// [`EINTR`]: crate::error::Errno::EINTR
#[track_caller]
fn pause_until<F, R>(&self, cond: F) -> Result<R>
where
F: FnMut() -> Option<R>,
@ -49,6 +50,7 @@ pub trait Pause: WaitTimeout {
///
/// [`ETIME`]: crate::error::Errno::ETIME
/// [`EINTR`]: crate::error::Errno::EINTR
#[track_caller]
fn pause_until_or_timeout<'a, F, T, R>(&self, mut cond: F, timeout: T) -> Result<R>
where
F: FnMut() -> Option<R>,
@ -74,6 +76,7 @@ pub trait Pause: WaitTimeout {
/// [`ETIME`]: crate::error::Errno::ETIME
/// [`EINTR`]: crate::error::Errno::EINTR
#[doc(hidden)]
#[track_caller]
fn pause_until_or_timeout_impl<F, R>(
&self,
cond: F,
@ -94,6 +97,7 @@ pub trait Pause: WaitTimeout {
///
/// [`ETIME`]: crate::error::Errno::ETIME
/// [`EINTR`]: crate::error::Errno::EINTR
#[track_caller]
fn pause_timeout<'a>(&self, timeout: impl Into<TimeoutExt<'a>>) -> Result<()>;
}

View File

@ -368,6 +368,7 @@ pub trait Pollable {
/// The user must ensure that a call to `try_op()` does not fail with `EAGAIN` when the
/// interesting events occur. However, it is allowed to have spurious `EAGAIN` failures due to
/// race opitions where the events are consumed by another thread.
#[track_caller]
fn wait_events<F, R>(
&self,
mask: IoEvents,

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();

View File

@ -17,6 +17,7 @@ pub trait WaitTimeout {
/// will return an error with [`ETIME`].
///
/// [`ETIME`]: crate::error::Errno::ETIME
#[track_caller]
fn wait_until_or_timeout<'a, F, T, R>(&self, mut cond: F, timeout: T) -> Result<R>
where
F: FnMut() -> Option<R>,
@ -41,6 +42,7 @@ pub trait WaitTimeout {
/// - an error with [`ETIME`] if the timeout is reached;
/// - the error returned by the cancel condition if the cancel condition returns `Err(_)`.
#[doc(hidden)]
#[track_caller]
fn wait_until_or_timeout_cancelled<F, R, FCancel>(
&self,
cond: F,