Make the gpui_tokio crate generic over the context it spawns (#23995)

Part of  #21092

Makes `Tokio::spawn` generic over any `AppContext`.

Also removes a stray `model_context` I missed

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2025-01-30 18:00:55 -08:00 committed by GitHub
parent ff43b6875b
commit 517e519bdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 133 additions and 18 deletions

View file

@ -155,7 +155,7 @@ pub use util::arc_cow::ArcCow;
pub use view::*;
pub use window::*;
use std::{any::Any, borrow::BorrowMut};
use std::{any::Any, borrow::BorrowMut, future::Future};
use taffy::TaffyLayoutEngine;
/// The context trait, allows the different contexts in GPUI to be used
@ -215,6 +215,16 @@ pub trait AppContext {
) -> Result<R>
where
T: 'static;
/// Spawn a future on a background thread
fn background_spawn<R>(&self, future: impl Future<Output = R> + Send + 'static) -> Task<R>
where
R: Send + 'static;
/// Read a global from this app context
fn read_global<G, R>(&self, callback: impl FnOnce(&G, &App) -> R) -> Self::Result<R>
where
G: Global;
}
/// Returned by [Context::reserve_entity] to later be passed to [Context::insert_model].