pub struct App {
pub store: Store,
pub metas: Vec<&'static ComponentMeta>,
pub shutdown_token: CancellationToken,
pub task_handle: RwLock<Option<JoinHandle<()>>>,
}Expand description
运行时 App — 持有所有已初始化的组件
Fields§
§store: Store§metas: Vec<&'static ComponentMeta>§shutdown_token: CancellationToken§task_handle: RwLock<Option<JoinHandle<()>>>Implementations§
Source§impl App
impl App
Sourcepub fn try_inject<T: Component>(&self) -> Option<Arc<T>>
pub fn try_inject<T: Component>(&self) -> Option<Arc<T>>
尝试获取组件,失败返回 None
Sourcepub async fn ins_run(self) -> RIE<Arc<App>>
pub async fn ins_run(self) -> RIE<Arc<App>>
异步运行 App,返回 Arc
初始化阶段(init + async_init)会在返回 Arc<App> 之前同步完成,
以确保组件完全就绪(如 AOP 拦截链注册、跨组件协作初始化)后再交予调用方使用。
仅长期运行的后台任务(async_run)放入独立 task 中持续运行,
直到 shutdown_token 触发才退出。
Sourcepub async fn waiting_exit(&self)
pub async fn waiting_exit(&self)
等待退出信号并优雅关闭
Auto Trait Implementations§
impl !Freeze for App
impl !RefUnwindSafe for App
impl !UnwindSafe for App
impl Send for App
impl Sync for App
impl Unpin for App
impl UnsafeUnpin for App
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