From a5d44de5c4cac9d266b7f24784c53e5e667b0991 Mon Sep 17 00:00:00 2001 From: Ashelyn Rose Date: Mon, 7 Oct 2024 21:40:31 -0600 Subject: Handle case where system has no members --- src/system/aggregator.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/system/aggregator.rs') diff --git a/src/system/aggregator.rs b/src/system/aggregator.rs index 8fbdfdd..52b1a8c 100644 --- a/src/system/aggregator.rs +++ b/src/system/aggregator.rs @@ -20,13 +20,14 @@ pub struct MessageAggregator { impl MessageAggregator { pub fn new(system_size: usize) -> Self { - let (tx, rx) = channel::(system_size * 2); + let buf_size = std::cmp::max(system_size * 2, 1); + let (tx, rx) = channel::(buf_size); Self { state: Arc::new(RwLock::new( AggregatorState { tx, rx, - message_cache: LruCache::new(NonZeroUsize::new(system_size * 2).unwrap()), + message_cache: LruCache::new(NonZeroUsize::new(buf_size).unwrap()), system_emitter: None, })) -- cgit 1.4.1