[−][src]Trait turbulence::runtime::Runtime
Trait for async runtime functionality needed by turbulence
.
This is designed so that it can be implemented on multiple platforms with multiple runtimes,
including wasm32-unknown-unknown
, where std::time::Instant
is unavailable.
Associated Types
Loading content...Required methods
fn spawn<F>(&self, future: F) where
F: Future<Output = ()> + Send + 'static,
F: Future<Output = ()> + Send + 'static,
This is similar to the futures::task::Spawn
trait, but it is generic in the spawned
future, which is better for backends like tokio.
fn now(&self) -> Self::Instant
Return the current instant.
fn elapsed(&self, instant: Self::Instant) -> Duration
Return the time elapsed since the given instant.
fn duration_between(
&self,
earlier: Self::Instant,
later: Self::Instant
) -> Duration
&self,
earlier: Self::Instant,
later: Self::Instant
) -> Duration
Similarly to std::time::Instant::duration_since
, may panic if later
comes before
earlier
.
fn sleep(&self, duration: Duration) -> Self::Sleep
Create a future which resolves after the given time has passed.
Implementations on Foreign Types
impl<'a, R: Runtime> Runtime for &'a R
[src]
type Instant = R::Instant
type Sleep = R::Sleep
fn spawn<F>(&self, future: F) where
F: Future<Output = ()> + Send + 'static,
[src]
F: Future<Output = ()> + Send + 'static,
fn now(&self) -> Self::Instant
[src]
fn elapsed(&self, instant: Self::Instant) -> Duration
[src]
fn duration_between(
&self,
earlier: Self::Instant,
later: Self::Instant
) -> Duration
[src]
&self,
earlier: Self::Instant,
later: Self::Instant
) -> Duration