Start removing the Send impl for App

Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-11-01 11:31:23 -07:00 committed by Nathan Sobo
parent ea7fdef417
commit 57ffa8201e
38 changed files with 506 additions and 932 deletions

View file

@ -26,8 +26,8 @@ use futures::{
};
use globset::{Glob, GlobSet, GlobSetBuilder};
use gpui2::{
AnyModel, AppContext, AsyncAppContext, Context, Entity, EventEmitter, Executor, Model,
ModelContext, Task, WeakModel,
AnyModel, AppContext, AsyncAppContext, BackgroundExecutor, Context, Entity, EventEmitter,
Model, ModelContext, Task, WeakModel,
};
use itertools::Itertools;
use language2::{
@ -207,7 +207,7 @@ impl DelayedDebounced {
let previous_task = self.task.take();
self.task = Some(cx.spawn(move |project, mut cx| async move {
let mut timer = cx.executor().timer(delay).fuse();
let mut timer = cx.background_executor().timer(delay).fuse();
if let Some(previous_task) = previous_task {
previous_task.await;
}
@ -1453,7 +1453,7 @@ impl Project {
};
if client.send(initial_state).log_err().is_some() {
let client = client.clone();
cx.executor()
cx.background_executor()
.spawn(async move {
let mut chunks = split_operations(operations).peekable();
while let Some(chunk) = chunks.next() {
@ -2436,7 +2436,7 @@ impl Project {
Duration::from_secs(1);
let task = cx.spawn(move |this, mut cx| async move {
cx.executor().timer(DISK_BASED_DIAGNOSTICS_DEBOUNCE).await;
cx.background_executor().timer(DISK_BASED_DIAGNOSTICS_DEBOUNCE).await;
if let Some(this) = this.upgrade() {
this.update(&mut cx, |this, cx| {
this.disk_based_diagnostics_finished(
@ -3477,7 +3477,7 @@ impl Project {
});
const PROCESS_TIMEOUT: Duration = Duration::from_secs(5);
let mut timeout = cx.executor().timer(PROCESS_TIMEOUT).fuse();
let mut timeout = cx.background_executor().timer(PROCESS_TIMEOUT).fuse();
let mut errored = false;
if let Some(mut process) = process {
@ -5741,7 +5741,7 @@ impl Project {
async fn background_search(
unnamed_buffers: Vec<Model<Buffer>>,
opened_buffers: HashMap<Arc<Path>, (Model<Buffer>, BufferSnapshot)>,
executor: Executor,
executor: BackgroundExecutor,
fs: Arc<dyn Fs>,
workers: usize,
query: SearchQuery,
@ -6376,7 +6376,7 @@ impl Project {
let snapshot =
worktree_handle.update(&mut cx, |tree, _| tree.as_local().unwrap().snapshot())?;
let diff_bases_by_buffer = cx
.executor()
.background_executor()
.spawn(async move {
future_buffers
.into_iter()
@ -7983,7 +7983,7 @@ impl Project {
// Any incomplete buffers have open requests waiting. Request that the host sends
// creates these buffers for us again to unblock any waiting futures.
for id in incomplete_buffer_ids {
cx.executor()
cx.background_executor()
.spawn(client.request(proto::OpenBufferById { project_id, id }))
.detach();
}
@ -8438,7 +8438,7 @@ impl Project {
let fs = self.fs.clone();
cx.spawn(move |this, mut cx| async move {
let prettier_dir = match cx
.executor()
.background_executor()
.spawn(Prettier::locate(
worktree_path.zip(buffer_path).map(
|(worktree_root_path, starting_path)| LocateStart {

View file

@ -22,7 +22,8 @@ use futures::{
use fuzzy2::CharBag;
use git::{DOT_GIT, GITIGNORE};
use gpui2::{
AppContext, AsyncAppContext, Context, EventEmitter, Executor, Model, ModelContext, Task,
AppContext, AsyncAppContext, BackgroundExecutor, Context, EventEmitter, Model, ModelContext,
Task,
};
use language2::{
proto::{
@ -600,7 +601,7 @@ impl LocalWorktree {
.update(&mut cx, |t, cx| t.as_local().unwrap().load(&path, cx))?
.await?;
let text_buffer = cx
.executor()
.background_executor()
.spawn(async move { text::Buffer::new(0, id, contents) })
.await;
cx.build_model(|_| Buffer::build(text_buffer, diff_base, Some(Arc::new(file))))
@ -888,7 +889,7 @@ impl LocalWorktree {
if let Some(repo) = snapshot.git_repositories.get(&*repo.work_directory) {
let repo = repo.repo_ptr.clone();
index_task = Some(
cx.executor()
cx.background_executor()
.spawn(async move { repo.lock().load_index_text(&repo_path) }),
);
}
@ -3012,7 +3013,7 @@ struct BackgroundScanner {
state: Mutex<BackgroundScannerState>,
fs: Arc<dyn Fs>,
status_updates_tx: UnboundedSender<ScanState>,
executor: Executor,
executor: BackgroundExecutor,
scan_requests_rx: channel::Receiver<ScanRequest>,
path_prefixes_to_scan_rx: channel::Receiver<Arc<Path>>,
next_entry_id: Arc<AtomicUsize>,
@ -3032,7 +3033,7 @@ impl BackgroundScanner {
next_entry_id: Arc<AtomicUsize>,
fs: Arc<dyn Fs>,
status_updates_tx: UnboundedSender<ScanState>,
executor: Executor,
executor: BackgroundExecutor,
scan_requests_rx: channel::Receiver<ScanRequest>,
path_prefixes_to_scan_rx: channel::Receiver<Arc<Path>>,
) -> Self {