Document why ForegroundExecutor is !Send (#25492)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-02-24 12:48:59 -07:00 committed by GitHub
parent 30af8d0a81
commit 8a3fb890b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -35,6 +35,11 @@ pub struct BackgroundExecutor {
/// A pointer to the executor that is currently running,
/// for spawning tasks on the main thread.
///
/// This is intentionally `!Send` via the `not_send` marker field. This is because
/// `ForegroundExecutor::spawn` does not require `Send` but checks at runtime that the future is
/// only polled from the same thread it was spawned from. These checks would fail when spawning
/// foreground tasks from from background threads.
#[derive(Clone)]
pub struct ForegroundExecutor {
#[doc(hidden)]