Skip to content

Commit 7bd34cb

Browse files
committed
Move TimeModels out of sync
1 parent f072dc5 commit 7bd34cb

File tree

11 files changed

+19
-11
lines changed

11 files changed

+19
-11
lines changed

shuttle/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ pub mod lazy_static;
187187
pub mod rand;
188188
pub mod sync;
189189
pub mod thread;
190+
pub mod time;
190191

191192
pub mod current;
192193
pub mod scheduler;

shuttle/src/runtime/execution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::runtime::task::{ChildLabelFn, Task, TaskId, TaskName, TaskSignature,
66
use crate::runtime::thread;
77
use crate::runtime::thread::continuation::PooledContinuation;
88
use crate::scheduler::{Schedule, Scheduler};
9-
use crate::sync::time::{get_time_model, TimeModel};
9+
use crate::time::{get_time_model, TimeModel};
1010
use crate::sync::{ResourceSignature, ResourceType};
1111
use crate::thread::thread_fn;
1212
use crate::{backtrace_enabled, Config, MaxSteps, UNGRACEFUL_SHUTDOWN_CONFIG};

shuttle/src/runtime/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::runtime::task::{Task, TaskId};
33
use crate::runtime::thread::continuation::{ContinuationPool, CONTINUATION_POOL};
44
use crate::scheduler::metrics::MetricsScheduler;
55
use crate::scheduler::{Schedule, Scheduler};
6-
use crate::sync::time::{frozen::FrozenTimeModel, TimeModel};
6+
use crate::time::{frozen::FrozenTimeModel, TimeModel};
77
use crate::Config;
88
use std::cell::RefCell;
99
use std::fmt;

shuttle/src/runtime/thread/continuation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::runtime::execution::ExecutionState;
2-
use crate::sync::time::get_time_model;
2+
use crate::time::get_time_model;
33
use crate::{ContinuationFunctionBehavior, UNGRACEFUL_SHUTDOWN_CONFIG};
44
use corosensei::Yielder;
55
use corosensei::{stack::DefaultStack, Coroutine, CoroutineResult};

shuttle/src/sync/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub mod mpsc;
77
mod mutex;
88
mod once;
99
mod rwlock;
10-
pub mod time;
1110

1211
pub use barrier::{Barrier, BarrierWaitResult};
1312
pub use condvar::{Condvar, WaitTimeoutResult};

shuttle/src/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
use crate::runtime::execution::ExecutionState;
44
use crate::runtime::task::TaskId;
55
use crate::runtime::thread;
6-
use crate::sync::time::Duration;
6+
use crate::time::Duration;
77
use std::fmt::Debug;
88
use std::marker::PhantomData;
99
use std::panic::Location;
1010
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
1111

12-
pub use crate::sync::time::sleep;
12+
pub use crate::time::sleep;
1313
pub use std::thread::{panicking, Result};
1414

1515
/// A unique identifier for a running thread
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::current::Labels;
2020
use crate::runtime::execution::ExecutionState;
2121

2222
use crate::runtime::thread;
23-
use crate::sync::time::frozen::FrozenTimeModel;
23+
use crate::time::frozen::FrozenTimeModel;
2424

2525
/// Constant stepped time model implementation
2626
pub mod constant_stepped;
@@ -50,23 +50,31 @@ pub trait TimeModel: std::fmt::Debug {
5050
/// Wake the next sleeping task; returns true if there exists a task that was able to be woken.
5151
/// Called when all tasks are blocked to resolve timing based deadlocks (all unblocked tasks are sleeping).
5252
fn wake_next(&mut self) -> bool;
53+
5354
/// Reset the TimeModel state for the next Shuttle iteration
5455
fn new_execution(&mut self);
56+
5557
/// Callback after each scheduling step to allow the TimeModel to update itself
5658
fn step(&mut self);
59+
5760
/// Used to create the TimeModel's Instant struct in functions like Instant::now()
5861
fn instant(&self) -> Instant;
62+
5963
/// Pauses the TimeModel
6064
fn pause(&mut self);
65+
6166
/// Resumes the TimeModel
6267
fn resume(&mut self);
68+
6369
/// Manually advances the TimeModel's clock by a fixed amount
6470
fn advance(&mut self, duration: Duration);
71+
6572
/// Callback for registering a sleep/timeout on the current task. It is up to the TimeModel
6673
/// implementation to determine when to wake the sleeping task. If no waker is provided, then
6774
/// the caller is polling whether it is currently expired but is not yet performing a blocking
6875
/// sleep.
6976
fn register_sleep(&mut self, deadline: Instant, id: u64, waker: Option<Waker>) -> bool;
77+
7078
/// Downcast to Any for type casting / checking
7179
fn as_any_mut(&mut self) -> &mut dyn std::any::Any;
7280
}

shuttle/tests/basic/pct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use shuttle::scheduler::PctScheduler;
2-
use shuttle::sync::time::Duration;
2+
use shuttle::time::Duration;
33
use shuttle::sync::Mutex;
44
use shuttle::{check_pct, check_random, thread, Config, MaxSteps, Runner};
55
use std::sync::atomic::AtomicUsize;

0 commit comments

Comments
 (0)