Skip to main content

BackendSessionHost

Trait BackendSessionHost 

Source
pub trait BackendSessionHost: BackendRuntimeCache {
    // Required method
    fn with_backend_session<R>(
        &mut self,
        f: impl FnOnce(&mut dyn BackendSession) -> R + Send,
    ) -> Result<R, SessionEntryError>
       where R: Send;
}
Expand description

Backend execution-session entry points.

with_backend_session is the canonical user entry and the only way an operation is reached from a backend; with_backend_session_cached is the runtime-cache-aware entry used by the runtime layer.

§Examples

use tenferro_tensor::BackendSessionHost;

fn accepts_session_host<B: BackendSessionHost>(_backend: &mut B) {}

The session factory this trait’s default bodies used to call was deleted with the one-shot spellings, so naming it does not compile:

ⓘ
use tenferro_tensor::default_backend_session;

Required Methods§

Source

fn with_backend_session<R>( &mut self, f: impl FnOnce(&mut dyn BackendSession) -> R + Send, ) -> Result<R, SessionEntryError>
where R: Send,

Open one backend session and run f inside it.

The session is built by the backend rather than by coercing the owner, so this is the only way an operation is reached from a backend.

Admission happens before f runs. A backend may wait for resources that another thread will release (CPU resource permits are granted in FIFO order), but it never runs f twice, never retries f through a fallback path, and never reports a failure of f as an admission failure: the callback’s own value, including its own Result, is returned unchanged in Ok.

§Errors

Returns SessionEntryError without running f when the backend cannot admit the session: SessionEntryError::Reentered for a nested entry on the calling thread, SessionEntryError::Contended for a busy resource that admission cannot wait for, SessionEntryError::IncompatibleContext for a mismatched execution scope or executor declaration, SessionEntryError::ResourcePoisoned for poisoned admission state, and SessionEntryError::Executor when the executor cannot be entered.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl BackendSessionHost for CpuBackend

Source§

fn with_backend_session<R>( &mut self, f: impl FnOnce(&mut dyn BackendSession) -> R + Send, ) -> Result<R, SessionEntryError>
where R: Send,

Implementors§