From 8a3fb890b0796b13c1dc9b1dc31ac8ae05cc02a0 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Mon, 24 Feb 2025 12:48:59 -0700 Subject: [PATCH] Document why `ForegroundExecutor` is `!Send` (#25492) Release Notes: - N/A --- crates/gpui/src/executor.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index c703f9cd3a..8b3e5c2359 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -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)]