pub struct SurfacePump<T: Send + 'static> { /* private fields */ }Expand description
Owning handle for the pump. On Windows, dropping it shuts the thread down (bounded join, then detach - a thread wedged in a driver call is left behind rather than hanging the GUI thread).
Implementations§
Source§impl<T: Send + 'static> SurfacePump<T>
impl<T: Send + 'static> SurfacePump<T>
Sourcepub unsafe fn spawn(
window: &Window<'_>,
device_lost: &Arc<AtomicBool>,
init: PumpInitFn<T>,
) -> Option<Self>
pub unsafe fn spawn( window: &Window<'_>, device_lost: &Arc<AtomicBool>, init: PumpInitFn<T>, ) -> Option<Self>
Build the pump for a baseview window. On Windows this spawns
the pump thread and returns immediately (GPU init runs there;
poll Self::take_init); elsewhere init runs synchronously
and take_init succeeds on the first call.
device_lost is raised if the pump thread panics so the
editor’s device-loss recovery can rebuild with a fresh pump.
§Safety
The window must remain valid while the pump lives - the editor guarantees this by dropping the pump before closing its child window (a destroyed HWND fails surface creation with a driver error, not UB).
Sourcepub fn take_init(&mut self) -> Option<T>
pub fn take_init(&mut self) -> Option<T>
Poll for the init closure’s product (non-blocking). Returns it exactly once.