From 7e56fafe31dd4c5720feb9e543d37176f672aee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20=E2=80=9CGoldstein=E2=80=9D=20Siling?= Date: Fri, 11 Aug 2023 16:38:12 +0300 Subject: [PATCH] fix(core/supervisor): pre-spawn actors in Multicast to avoid deadlock (#105) --- elfo-core/src/supervisor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/elfo-core/src/supervisor.rs b/elfo-core/src/supervisor.rs index e398fe1d..0d801315 100644 --- a/elfo-core/src/supervisor.rs +++ b/elfo-core/src/supervisor.rs @@ -226,7 +226,12 @@ where None => visitor.empty(envelope), }, Outcome::Multicast(list) => { - let iter = list.into_iter().filter_map(|key| get_or_spawn!(self, key)); + for key in list.iter() { + if !self.objects.contains_key(key) { + get_or_spawn!(self, key.clone()); + } + } + let iter = list.into_iter().filter_map(|key| self.objects.get(&key)); self.visit_multiple(envelope, visitor, iter); } Outcome::GentleMulticast(list) => {