diff options
| author | mat <git@matdoes.dev> | 2023-11-18 00:07:25 -0600 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-11-18 00:07:25 -0600 |
| commit | e39de79a6b5913cab2ee59cff492317a24726ba4 (patch) | |
| tree | a2560e94b9a49c263f8da60bafd2ad3bf5dae19f /azalea/src | |
| parent | 03cc28d8e71ed969b21a0824a93dd8e2671e3178 (diff) | |
| download | azalea-drasl-e39de79a6b5913cab2ee59cff492317a24726ba4.tar.xz | |
simplify some code
Diffstat (limited to 'azalea/src')
| -rw-r--r-- | azalea/src/swarm/mod.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/azalea/src/swarm/mod.rs b/azalea/src/swarm/mod.rs index 1f31db98..585e2608 100644 --- a/azalea/src/swarm/mod.rs +++ b/azalea/src/swarm/mod.rs @@ -393,7 +393,10 @@ where if let Some(handler) = &self.handler { let first_bot_state = first_bot.component::<S>(); let first_bot_entity = first_bot.entity; - tokio::spawn((handler)(first_bot, first_event, first_bot_state.clone())); + + let mut tasks = Vec::new(); + + tasks.push((handler)(first_bot, first_event, first_bot_state.clone())); // this makes it not have to keep locking the ecs let mut states = HashMap::new(); @@ -402,8 +405,10 @@ where let state = states .entry(bot.entity) .or_insert_with(|| bot.component::<S>().clone()); - tokio::spawn((handler)(bot, event, state.clone())); + tasks.push((handler)(bot, event, state.clone())); } + + tokio::spawn(join_all(tasks)); } } |
