pub struct SerialCtx<'a> { /* private fields */ }Expand description
The serial context CpuEngine::with_guard lends: the engine’s workspace
and batch policy, without a placement token.
It is not a provider bundle and cannot fork. A caller that hands serial work
to a provider builds a budget-one bundle from it with
cpueinsum::Exec::serial_with_workspace, which takes no token from the
engine’s pool.
§Examples
let mut engine = tenferro_cpu::CpuEngine::serial();
let budget = engine.with_guard(|ctx| {
cpueinsum::Exec::serial_with_workspace(ctx.workspace())
.with_batch_policy(ctx.batch_policy())
.budget()
})?;
assert_eq!(budget, 1);Implementations§
Source§impl<'a> SerialCtx<'a>
impl<'a> SerialCtx<'a>
Sourcepub fn workspace(&self) -> &'a dyn WorkspaceProvider
pub fn workspace(&self) -> &'a dyn WorkspaceProvider
The engine’s scratch provider, the one its tokens’ bundles use.
§Examples
let mut engine = tenferro_cpu::CpuEngine::serial();
let has_workspace = engine.with_guard(|ctx| {
cpueinsum::Exec::serial_with_workspace(ctx.workspace())
.workspace()
.is_some()
})?;
assert!(has_workspace);Sourcepub fn batch_policy(&self) -> CpuBatchPolicy
pub fn batch_policy(&self) -> CpuBatchPolicy
The engine’s batch policy (see CpuEngine::batch_policy).
§Examples
let mut engine = tenferro_cpu::CpuEngine::serial();
let policy = engine.with_guard(|ctx| ctx.batch_policy())?;
assert_eq!(policy, engine.batch_policy());Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SerialCtx<'a>
impl<'a> RefUnwindSafe for SerialCtx<'a>
impl<'a> Send for SerialCtx<'a>
impl<'a> Sync for SerialCtx<'a>
impl<'a> Unpin for SerialCtx<'a>
impl<'a> UnsafeUnpin for SerialCtx<'a>
impl<'a> UnwindSafe for SerialCtx<'a>
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
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more