pub struct EngineRuntime { /* private fields */ }Expand description
Owns the engine thread and exposes a synchronous facade.
Drop semantics: dropping the runtime closes the command channel, which causes the engine thread to exit its loop and drop the engine. The destructor joins the thread.
Implementations§
Source§impl EngineRuntime
impl EngineRuntime
Sourcepub fn spawn<F>(make: F) -> EngineResult<Self>
pub fn spawn<F>(make: F) -> EngineResult<Self>
Spawn the engine thread and construct the engine on that thread
via make. This is the only correct construction point: the
platform run loop must be initialized on the same thread that
later drives WebKit.
Returns once the engine thread has signaled it is ready.
Sourcepub fn dispatcher(engine: Box<dyn Engine>) -> (Self, MainThreadDispatcher)
pub fn dispatcher(engine: Box<dyn Engine>) -> (Self, MainThreadDispatcher)
Construct a runtime whose engine runs on the caller’'‘s thread.
No internal thread is spawned. The returned MainThreadDispatcher
drives the engine: call MainThreadDispatcher::tick in the
caller’'’s loop to drain one queued job, or [MainThreadDispatcher::run_until]
to block until a stop flag fires.
Use this when the engine is bound to a specific OS thread (e.g.
the macOS Cocoa main thread, where WKWebView must run).
Sourcepub fn shutdown(&mut self)
pub fn shutdown(&mut self)
Cleanly shut down: close the channel and join the thread. Idempotent — calling shutdown twice is a no-op.