pub struct KernelRunner<S: KernelState> { /* private fields */ }Expand description
Runner that executes the kernel with correct runtime handling.
- Sync: Runs the kernel on a dedicated thread with its own Tokio runtime, so you can call from any thread without an existing runtime.
- Async: Uses
spawn_blockingso the kernel runs on a blocking thread and does not block the async reactor.
Implementations§
Source§impl<S: KernelState> KernelRunner<S>
impl<S: KernelState> KernelRunner<S>
Sourcepub fn new(kernel: Kernel<S>) -> Self
pub fn new(kernel: Kernel<S>) -> Self
Creates a runner that will use the given kernel for all runs.
Sourcepub fn run_until_blocked_sync(
&self,
run_id: &RunId,
initial_state: S,
) -> Result<RunStatus, KernelError>
pub fn run_until_blocked_sync( &self, run_id: &RunId, initial_state: S, ) -> Result<RunStatus, KernelError>
Sync entry: runs until blocked/completed on a dedicated thread with an internal runtime. Blocks the current thread until the run finishes.
Sourcepub async fn run_until_blocked_async(
&self,
run_id: &RunId,
initial_state: S,
) -> Result<RunStatus, KernelError>
pub async fn run_until_blocked_async( &self, run_id: &RunId, initial_state: S, ) -> Result<RunStatus, KernelError>
Async entry: runs the kernel inside spawn_blocking so the async reactor
is not blocked. Use from async code without deadlock.
Sourcepub fn resume_sync(
&self,
run_id: &RunId,
initial_state: S,
signal: Signal,
) -> Result<RunStatus, KernelError>
pub fn resume_sync( &self, run_id: &RunId, initial_state: S, signal: Signal, ) -> Result<RunStatus, KernelError>
Sync resume: same as run_until_blocked_sync but after appending a resume event.
Sourcepub async fn resume_async(
&self,
run_id: &RunId,
initial_state: S,
signal: Signal,
) -> Result<RunStatus, KernelError>
pub async fn resume_async( &self, run_id: &RunId, initial_state: S, signal: Signal, ) -> Result<RunStatus, KernelError>
Async resume: same as run_until_blocked_async but after appending a resume event.
Auto Trait Implementations§
impl<S> Freeze for KernelRunner<S>
impl<S> !RefUnwindSafe for KernelRunner<S>
impl<S> Send for KernelRunner<S>
impl<S> Sync for KernelRunner<S>
impl<S> Unpin for KernelRunner<S>
impl<S> UnsafeUnpin for KernelRunner<S>
impl<S> !UnwindSafe for KernelRunner<S>
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