mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 08:26:30 +00:00
Make *_or_timeout
APIs concise
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
10cc85d588
commit
32b8e05cc3
@ -14,7 +14,7 @@ use crate::{
|
||||
clocks::{MonotonicClock, RealTimeClock},
|
||||
timer::Timeout,
|
||||
timespec_t,
|
||||
wait::TimerBuilder,
|
||||
wait::ManagedTimeout,
|
||||
},
|
||||
};
|
||||
|
||||
@ -40,7 +40,7 @@ pub fn sys_futex(
|
||||
Ok(val as usize)
|
||||
};
|
||||
|
||||
let get_futex_timer_builder = |timeout_addr: Vaddr| -> Result<Option<TimerBuilder<'static>>> {
|
||||
let get_futex_timeout = |timeout_addr: Vaddr| -> Result<Option<ManagedTimeout<'static>>> {
|
||||
if timeout_addr == 0 {
|
||||
return Ok(None);
|
||||
}
|
||||
@ -78,7 +78,7 @@ pub fn sys_futex(
|
||||
MonotonicClock::timer_manager()
|
||||
};
|
||||
|
||||
Ok(Some(TimerBuilder::new_with_timer_manager(
|
||||
Ok(Some(ManagedTimeout::new_with_manager(
|
||||
timeout,
|
||||
timer_manager,
|
||||
)))
|
||||
@ -91,15 +91,15 @@ pub fn sys_futex(
|
||||
};
|
||||
let res = match futex_op {
|
||||
FutexOp::FUTEX_WAIT => {
|
||||
let timer_builder = get_futex_timer_builder(utime_addr)?;
|
||||
futex_wait(futex_addr as _, futex_val as _, timer_builder, ctx, pid).map(|_| 0)
|
||||
let timeout = get_futex_timeout(utime_addr)?;
|
||||
futex_wait(futex_addr as _, futex_val as _, timeout, ctx, pid).map(|_| 0)
|
||||
}
|
||||
FutexOp::FUTEX_WAIT_BITSET => {
|
||||
let timer_builder = get_futex_timer_builder(utime_addr)?;
|
||||
let timeout = get_futex_timeout(utime_addr)?;
|
||||
futex_wait_bitset(
|
||||
futex_addr as _,
|
||||
futex_val as _,
|
||||
timer_builder,
|
||||
timeout,
|
||||
bitset as _,
|
||||
ctx,
|
||||
pid,
|
||||
|
@ -12,7 +12,7 @@ use crate::{
|
||||
clocks::{BootTimeClock, MonotonicClock, RealTimeClock},
|
||||
timer::Timeout,
|
||||
timespec_t,
|
||||
wait::TimerBuilder,
|
||||
wait::ManagedTimeout,
|
||||
TIMER_ABSTIME,
|
||||
},
|
||||
};
|
||||
@ -109,10 +109,11 @@ fn do_clock_nanosleep(
|
||||
}
|
||||
};
|
||||
|
||||
let timer_builder =
|
||||
TimerBuilder::new_with_timer_manager(Timeout::After(duration), timer_manager);
|
||||
let res = waiter.pause_until_or_timeout(
|
||||
|| None,
|
||||
ManagedTimeout::new_with_manager(Timeout::After(duration), timer_manager),
|
||||
);
|
||||
|
||||
let res = waiter.pause_until_or_timer_timeout(|| None, &timer_builder);
|
||||
match res {
|
||||
Err(e) if e.error() == Errno::ETIME => Ok(SyscallReturn::Return(0)),
|
||||
Err(e) if e.error() == Errno::EINTR => {
|
||||
|
Reference in New Issue
Block a user