Skip to content

Commit 752efba

Browse files
committed
Copilot fixes
1 parent 0e91065 commit 752efba

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

library/std/src/sys/pal/xous/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub const UNIX_EPOCH: SystemTime = SystemTime(Duration::from_secs(0));
1414
impl Instant {
1515
pub fn now() -> Instant {
1616
let result = blocking_scalar(ticktimer_server(), ElapsedNs.into())
17-
.expect("failed to request elapsed_ms");
17+
.expect("failed to request elapsed");
1818
let lower = result[0];
1919
let upper = result[1];
2020
Instant { 0: Duration::from_nanos(lower as u64 | (upper as u64) << 32) }

library/std/src/sys/sync/condvar/xous.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Condvar {
6262
// Returns false on timeout
6363
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
6464
let mut nanos = dur.as_nanos() as u64;
65-
// Ensure we don't wait for 0 ms, which would cause us to wait forever
65+
// Ensure we don't send zero as parameter, as it could be handled special in the future.
6666
if nanos == 0 {
6767
nanos = 1;
6868
}

library/std/src/sys/sync/thread_parking/xous.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ impl Parker {
3030
self.mtx.unlock();
3131
}
3232

33-
pub unsafe fn park_timeout(self: Pin<&Self>, timeout: Duration) {
33+
pub unsafe fn park_timeout(self: Pin<&Self>, mut timeout: Duration) {
3434
self.mtx.lock();
35-
while !self.token.load(Ordering::SeqCst) {
35+
while timeout > Duration::ZERO && !self.token.load(Ordering::SeqCst) {
36+
let start = crate::time::Instant::now();
3637
self.condvar.wait_timeout(&self.mtx, timeout);
38+
timeout = timeout.saturating_sub(start.elapsed());
3739
}
3840
self.token.store(false, Ordering::SeqCst);
3941
self.mtx.unlock();

0 commit comments

Comments
 (0)