@@ -469,13 +469,17 @@ impl EventState {
469
469
self . hover_icon = icon;
470
470
}
471
471
472
- /// Push a message to the stack via a [`Future`]
472
+ /// Asynchronously push a message to the stack via a [`Future`]
473
473
///
474
- /// Expects a future which, on completion, returns a message.
475
- /// This message is then pushed to the message stack as if it were pushed
476
- /// with [`Self::push `] from widget `id` .
474
+ /// The future is polled after event handling and after drawing and is able
475
+ /// to wake the event loop. This future is executed on the main thread; for
476
+ /// high-CPU tasks use [`Self::push_spawn `] instead .
477
477
///
478
- /// The future will be polled before the event loop sleeps.
478
+ /// The future must resolve to a message on completion. This message is
479
+ /// pushed to the message stack as if it were pushed with [`EventMgr::push`]
480
+ /// from widget `id`, allowing this widget or any ancestor to handle it in
481
+ /// [`Widget::handle_message`].
482
+ //
479
483
// TODO: Can we identify the calling widget `id` via the context (EventMgr)?
480
484
pub fn push_async < Fut , M > ( & mut self , id : WidgetId , fut : Fut )
481
485
where
@@ -485,13 +489,9 @@ impl EventState {
485
489
self . push_async_erased ( id, async { Erased :: new ( fut. await ) } ) ;
486
490
}
487
491
488
- /// Push a type-erased message to the stack via a [`Future`]
492
+ /// Asynchronously push a type-erased message to the stack via a [`Future`]
489
493
///
490
- /// Expects a future which, on completion, returns a message.
491
- /// This message is then pushed to the message stack as if it were pushed
492
- /// with [`Self::push_erased`] from widget `id`.
493
- ///
494
- /// The future will be polled before the event loop sleeps.
494
+ /// This is a low-level variant of [`Self::push_async`].
495
495
pub fn push_async_erased < Fut > ( & mut self , id : WidgetId , fut : Fut )
496
496
where
497
497
Fut : IntoFuture < Output = Erased > + ' static ,
@@ -502,14 +502,14 @@ impl EventState {
502
502
503
503
/// Spawn a task, run on a thread pool
504
504
///
505
- /// This method is similar to [`Self::push_async`], except that the future
506
- /// is run on a worker thread (appropriate when significant CPU work is
507
- /// required).
508
- ///
509
- /// The future will be spawned before the event loop sleeps.
505
+ /// The future is spawned to a thread-pool before the event-handling loop
506
+ /// sleeps, and is able to wake the loop on completion. Tasks involving
507
+ /// significant CPU work should use this method over [`Self::push_async`].
510
508
///
511
- /// Uses [`async-global-executor`].
512
- /// See crate documentation for configuration.
509
+ /// This method is simply a wrapper around [`async_global_executor::spawn`]
510
+ /// and [`Self::push_async`]; if a different multi-threaded executor is
511
+ /// available, that may be used instead. See also [`async_global_executor`]
512
+ /// documentation of configuration.
513
513
#[ cfg( feature = "spawn" ) ]
514
514
#[ cfg_attr( doc_cfg, doc( cfg( feature = "spawn" ) ) ) ]
515
515
pub fn push_spawn < Fut , M > ( & mut self , id : WidgetId , fut : Fut )
0 commit comments