pub struct LayoutWorker<S: LayoutSim> { /* private fields */ }Expand description
后台布局线程句柄。泛型驱动 LayoutSim,视图层用别名
LayoutWorker2D / LayoutWorker3D。
Implementations§
Source§impl<S: LayoutSim> LayoutWorker<S>
impl<S: LayoutSim> LayoutWorker<S>
Sourcepub fn spawn(config: LayoutConfig, payload: GraphPayload) -> Self
pub fn spawn(config: LayoutConfig, payload: GraphPayload) -> Self
启动后台布局线程。
Sourcepub fn send(&self, cmd: LayoutCommand<S::Pos>)
pub fn send(&self, cmd: LayoutCommand<S::Pos>)
发送命令(通道关闭时静默丢弃——worker 已停)。
Sourcepub fn try_message(&mut self) -> Option<LayoutMessage<S::Pos>>
pub fn try_message(&mut self) -> Option<LayoutMessage<S::Pos>>
非阻塞取走一条消息(信箱是单槽,UI 每帧调用一次即可)。
Poisoned 表示布局线程 panic,用 Self::restart 重启。
Sourcepub fn try_snapshot(&mut self) -> Option<LayoutSnapshot<S::Pos>>
pub fn try_snapshot(&mut self) -> Option<LayoutSnapshot<S::Pos>>
每帧取最新快照的便捷方法;线程中毒返回 None(配合 Self::is_poisoned)。
Sourcepub fn is_poisoned(&self) -> bool
pub fn is_poisoned(&self) -> bool
布局线程是否已 panic(可 Self::restart)。
Sourcepub fn rerun(&mut self, config: LayoutConfig, payload: GraphPayload)
pub fn rerun(&mut self, config: LayoutConfig, payload: GraphPayload)
彻底重跑:换配置 / 换图数据并重启线程。
Trait Implementations§
Source§impl<S: LayoutSim> Drop for LayoutWorker<S>
impl<S: LayoutSim> Drop for LayoutWorker<S>
Auto Trait Implementations§
impl<S> !RefUnwindSafe for LayoutWorker<S>
impl<S> !UnwindSafe for LayoutWorker<S>
impl<S> Forget for LayoutWorker<S>
impl<S> Freeze for LayoutWorker<S>where
*mut Counter<Channel<LayoutCommand<<S as LayoutSim>::Pos>>>: Freeze,
*mut Counter<Channel<LayoutCommand<<S as LayoutSim>::Pos>>>: Freeze,
*mut Counter<Channel<LayoutCommand<<S as LayoutSim>::Pos>>>: Freeze,
*const ArcInner<Mutex<Option<LayoutMessage<<S as LayoutSim>::Pos>>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<Option<LayoutMessage<<S as LayoutSim>::Pos>>>>>: Freeze,
*const ArcInner<Atomic<bool>> is !null: Freeze,
PhantomData<ArcInner<Atomic<bool>>>: Freeze,
*const ArcInner<Inner> is !null: Freeze,
PhantomData<ArcInner<Inner>>: Freeze,
*const ArcInner<Packet<'static, ()>> is !null: Freeze,
PhantomData<ArcInner<Packet<'static, ()>>>: Freeze,
*const ArcInner<GraphPayload> is !null: Freeze,
PhantomData<ArcInner<GraphPayload>>: Freeze,
impl<S> Move for LayoutWorker<S>
impl<S> Send for LayoutWorker<S>
impl<S> Sync for LayoutWorker<S>
impl<S> Unpin for LayoutWorker<S>where
*mut Counter<Channel<LayoutCommand<<S as LayoutSim>::Pos>>>: Unpin,
*mut Counter<Channel<LayoutCommand<<S as LayoutSim>::Pos>>>: Unpin,
*mut Counter<Channel<LayoutCommand<<S as LayoutSim>::Pos>>>: Unpin,
Arc<Mutex<Option<LayoutMessage<<S as LayoutSim>::Pos>>>>: Unpin,
Arc<Atomic<bool>>: Unpin,
Arc<Inner, System>: Unpin,
Arc<Packet<'static, ()>>: Unpin,
Arc<GraphPayload>: Unpin,
impl<S> UnsafeUnpin for LayoutWorker<S>where
*mut Counter<Channel<LayoutCommand<<S as LayoutSim>::Pos>>>: UnsafeUnpin,
*mut Counter<Channel<LayoutCommand<<S as LayoutSim>::Pos>>>: UnsafeUnpin,
*mut Counter<Channel<LayoutCommand<<S as LayoutSim>::Pos>>>: UnsafeUnpin,
*const ArcInner<Mutex<Option<LayoutMessage<<S as LayoutSim>::Pos>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<Option<LayoutMessage<<S as LayoutSim>::Pos>>>>>: UnsafeUnpin,
*const ArcInner<Atomic<bool>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Atomic<bool>>>: UnsafeUnpin,
*const ArcInner<Inner> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner>>: UnsafeUnpin,
*const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin,
*const ArcInner<GraphPayload> is !null: UnsafeUnpin,
PhantomData<ArcInner<GraphPayload>>: UnsafeUnpin,
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