Skip to content

Commit

Permalink
also stop watching sucessfully cancelled tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
kralverde committed Oct 29, 2024
1 parent 8feb728 commit 350d9f2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pumpkin/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ impl World {
let id = uuid::Uuid::new_v4();

let (chunks, handles, mut receiver) = self.receive_chunks(chunks);
{

let ids = {
let mut pending_chunks = player.pending_chunks.lock();

for chunk in &chunks {
Expand All @@ -367,7 +368,7 @@ impl World {

let ids = player.client.watch_expensive_tasks(handles);

for (chunk, task_id) in chunks.into_iter().zip(ids.into_iter()) {
for (chunk, task_id) in chunks.into_iter().zip(ids.iter().copied()) {
let entry = pending_chunks.entry(chunk);
match entry {
Entry::Occupied(mut entry) => {
Expand All @@ -380,7 +381,10 @@ impl World {
}
};
}
}

ids
};

let pending_chunks = player.pending_chunks.clone();
let level = self.level.clone();
let retained_player = player.clone();
Expand Down Expand Up @@ -454,6 +458,12 @@ impl World {
}
}

// Remove all canceled chunks
for task_id in ids {
player.client.stop_watching_expensive_task(&task_id);
log::debug!("Aborted task {} (pre-process)", task_id,);
}

{
let mut batch = player.pending_chunk_batch.lock();
batch.remove(&batch_id);
Expand Down

0 comments on commit 350d9f2

Please sign in to comment.