rt: move internal clock fns out of context (#5139)

A step towards getting rid of `runtime::context`. Internal functions
related to getting the current clock are moved to the time driver.
This commit is contained in:
Carl Lerche
2022-10-27 14:18:39 -07:00
committed by GitHub
parent 6c19748f90
commit 5c2e275659
2 changed files with 7 additions and 17 deletions
-16
View File
@@ -24,22 +24,6 @@ pub(crate) fn current() -> Handle {
}
}
cfg_time! {
cfg_test_util! {
pub(crate) fn clock() -> Option<crate::runtime::driver::Clock> {
match CONTEXT.try_with(|ctx| {
let ctx = ctx.borrow();
ctx
.as_ref()
.map(|ctx| ctx.inner.clock().clone())
}) {
Ok(clock) => clock,
Err(_) => panic!("{}", crate::util::error::THREAD_LOCAL_DESTROYED_ERROR),
}
}
}
}
/// Sets this [`Handle`] as the current active [`Handle`].
///
/// [`Handle`]: Handle
+7 -1
View File
@@ -33,7 +33,13 @@ cfg_test_util! {
cfg_rt! {
fn clock() -> Option<Clock> {
crate::runtime::context::clock()
use crate::runtime::Handle;
match Handle::try_current() {
Ok(handle) => Some(handle.inner.clock().clone()),
Err(ref e) if e.is_missing_context() => None,
Err(_) => panic!("{}", crate::util::error::THREAD_LOCAL_DESTROYED_ERROR),
}
}
}