Split out a foreground and background executor
This commit is contained in:
parent
dd1a2a9e44
commit
11b6d9e33a
26 changed files with 165 additions and 150 deletions
|
@ -365,10 +365,10 @@ impl Worktree {
|
|||
})
|
||||
.detach();
|
||||
|
||||
let background_scanner_task = cx.executor().spawn({
|
||||
let background_scanner_task = cx.background_executor().spawn({
|
||||
let fs = fs.clone();
|
||||
let snapshot = snapshot.clone();
|
||||
let background = cx.executor().clone();
|
||||
let background = cx.background_executor().clone();
|
||||
async move {
|
||||
let events = fs.watch(&abs_path, Duration::from_millis(100)).await;
|
||||
BackgroundScanner::new(
|
||||
|
@ -429,7 +429,7 @@ impl Worktree {
|
|||
let background_snapshot = Arc::new(Mutex::new(snapshot.clone()));
|
||||
let (mut snapshot_updated_tx, mut snapshot_updated_rx) = watch::channel();
|
||||
|
||||
cx.executor()
|
||||
cx.background_executor()
|
||||
.spawn({
|
||||
let background_snapshot = background_snapshot.clone();
|
||||
async move {
|
||||
|
@ -1008,7 +1008,7 @@ impl LocalWorktree {
|
|||
let lowest_ancestor = self.lowest_ancestor(&path);
|
||||
let abs_path = self.absolutize(&path);
|
||||
let fs = self.fs.clone();
|
||||
let write = cx.executor().spawn(async move {
|
||||
let write = cx.background_executor().spawn(async move {
|
||||
if is_dir {
|
||||
fs.create_dir(&abs_path).await
|
||||
} else {
|
||||
|
@ -1058,7 +1058,7 @@ impl LocalWorktree {
|
|||
let abs_path = self.absolutize(&path);
|
||||
let fs = self.fs.clone();
|
||||
let write = cx
|
||||
.executor()
|
||||
.background_executor()
|
||||
.spawn(async move { fs.save(&abs_path, &text, line_ending).await });
|
||||
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
|
@ -1079,7 +1079,7 @@ impl LocalWorktree {
|
|||
let abs_path = self.absolutize(&entry.path);
|
||||
let fs = self.fs.clone();
|
||||
|
||||
let delete = cx.executor().spawn(async move {
|
||||
let delete = cx.background_executor().spawn(async move {
|
||||
if entry.is_file() {
|
||||
fs.remove_file(&abs_path, Default::default()).await?;
|
||||
} else {
|
||||
|
@ -1119,7 +1119,7 @@ impl LocalWorktree {
|
|||
let abs_old_path = self.absolutize(&old_path);
|
||||
let abs_new_path = self.absolutize(&new_path);
|
||||
let fs = self.fs.clone();
|
||||
let rename = cx.executor().spawn(async move {
|
||||
let rename = cx.background_executor().spawn(async move {
|
||||
fs.rename(&abs_old_path, &abs_new_path, Default::default())
|
||||
.await
|
||||
});
|
||||
|
@ -1146,7 +1146,7 @@ impl LocalWorktree {
|
|||
let abs_old_path = self.absolutize(&old_path);
|
||||
let abs_new_path = self.absolutize(&new_path);
|
||||
let fs = self.fs.clone();
|
||||
let copy = cx.executor().spawn(async move {
|
||||
let copy = cx.background_executor().spawn(async move {
|
||||
copy_recursive(
|
||||
fs.as_ref(),
|
||||
&abs_old_path,
|
||||
|
@ -1174,7 +1174,7 @@ impl LocalWorktree {
|
|||
) -> Option<Task<Result<()>>> {
|
||||
let path = self.entry_for_id(entry_id)?.path.clone();
|
||||
let mut refresh = self.refresh_entries_for_paths(vec![path]);
|
||||
Some(cx.executor().spawn(async move {
|
||||
Some(cx.background_executor().spawn(async move {
|
||||
refresh.next().await;
|
||||
Ok(())
|
||||
}))
|
||||
|
@ -1248,7 +1248,7 @@ impl LocalWorktree {
|
|||
.ok();
|
||||
|
||||
let worktree_id = cx.entity_id().as_u64();
|
||||
let _maintain_remote_snapshot = cx.executor().spawn(async move {
|
||||
let _maintain_remote_snapshot = cx.background_executor().spawn(async move {
|
||||
let mut is_first = true;
|
||||
while let Some((snapshot, entry_changes, repo_changes)) = snapshots_rx.next().await {
|
||||
let update;
|
||||
|
@ -1306,7 +1306,7 @@ impl LocalWorktree {
|
|||
let rx = self.observe_updates(project_id, cx, move |update| {
|
||||
client.request(update).map(|result| result.is_ok())
|
||||
});
|
||||
cx.executor()
|
||||
cx.background_executor()
|
||||
.spawn(async move { rx.await.map_err(|_| anyhow!("share ended")) })
|
||||
}
|
||||
|
||||
|
@ -2672,7 +2672,8 @@ impl language2::LocalFile for File {
|
|||
let worktree = self.worktree.read(cx).as_local().unwrap();
|
||||
let abs_path = worktree.absolutize(&self.path);
|
||||
let fs = worktree.fs.clone();
|
||||
cx.executor().spawn(async move { fs.load(&abs_path).await })
|
||||
cx.background_executor()
|
||||
.spawn(async move { fs.load(&abs_path).await })
|
||||
}
|
||||
|
||||
fn buffer_reloaded(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue