Skip to main content

LayoutWorker

Struct LayoutWorker 

Source
pub struct LayoutWorker<S: LayoutSim> { /* private fields */ }
Expand description

后台布局线程句柄。泛型驱动 LayoutSim,视图层用别名 LayoutWorker2D / LayoutWorker3D。

Implementations§

Source§

impl<S: LayoutSim> LayoutWorker<S>

Source

pub fn spawn(config: LayoutConfig, payload: GraphPayload) -> Self

启动后台布局线程。

Source

pub fn send(&self, cmd: LayoutCommand<S::Pos>)

发送命令(通道关闭时静默丢弃——worker 已停)。

Source

pub fn try_message(&mut self) -> Option<LayoutMessage<S::Pos>>

非阻塞取走一条消息(信箱是单槽,UI 每帧调用一次即可)。 Poisoned 表示布局线程 panic,用 Self::restart 重启。

Source

pub fn try_snapshot(&mut self) -> Option<LayoutSnapshot<S::Pos>>

每帧取最新快照的便捷方法;线程中毒返回 None(配合 Self::is_poisoned)。

Source

pub fn is_poisoned(&self) -> bool

布局线程是否已 panic(可 Self::restart)。

Source

pub fn restart(&mut self)

重启布局线程(panic 后或需要彻底重跑时)。沿用当前配置与初始图数据。

Source

pub fn rerun(&mut self, config: LayoutConfig, payload: GraphPayload)

彻底重跑:换配置 / 换图数据并重启线程。

Trait Implementations§

Source§

impl<S: LayoutSim> Drop for LayoutWorker<S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.