pub struct ReferenceCarrier {}Expand description
Carries the calling thread’s reference datetime into a parallel section.
The reference datetime belongs to one thread, so a rayon worker or a blocking
task does not see the one its caller set. Without the clock feature that would
make the same call give an answer serially and fail in parallel, so every parallel
section that can reach evaluation_time or resolution_base captures the
reference first and runs its work through it:
use optionstratlib_core::utils::time::ReferenceCarrier;
let carrier = ReferenceCarrier::capture();
let work = move |x: i32| carrier.run(|| x + 1);
assert_eq!(work(1), 2);With the clock feature it does nothing: a worker there measures from the wall
clock, as it always has, so a default build is unchanged.
Implementations§
Trait Implementations§
Source§impl Clone for ReferenceCarrier
impl Clone for ReferenceCarrier
impl Copy for ReferenceCarrier
Auto Trait Implementations§
impl Forget for ReferenceCarrier
impl Freeze for ReferenceCarrier
impl RefUnwindSafe for ReferenceCarrier
impl Send for ReferenceCarrier
impl Sync for ReferenceCarrier
impl Unpin for ReferenceCarrier
impl UnsafeUnpin for ReferenceCarrier
impl UnwindSafe for ReferenceCarrier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more