diff --git a/Cargo.toml b/Cargo.toml index 92e91a4..f22583f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,6 @@ [package] name = "messagebus" -<<<<<<< HEAD -version = "0.5.0" -======= -version = "0.5.1" ->>>>>>> db1727b (Local Handlers) +version = "0.5.2" authors = ["Andrey Tkachenko "] repository = "https://github.com/andreytkachenko/messagebus.git" keywords = ["futures", "async", "tokio", "message", "bus"] diff --git a/src/builder.rs b/src/builder.rs index 2470dd8..63e53ec 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -140,7 +140,7 @@ impl BusBuilder { pub fn register(self, item: T) -> RegisterEntry { RegisterEntry { - item: Untyped::new_rwlock(item), + item: Untyped::new_readonly(item), builder: self, receivers: HashMap::new(), _m: Default::default(), diff --git a/src/lib.rs b/src/lib.rs index 20356a1..beddada 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,8 +59,7 @@ impl BusInner { pub fn try_send(&self, msg: M) -> core::result::Result<(), SendError> { if self.closed.load(Ordering::SeqCst) { - println!("Bus closed. Skipping send!"); - return Ok(()); + return Err(SendError::Closed(msg)); } let tid = TypeId::of::(); @@ -71,7 +70,7 @@ impl BusInner { } if let Some((_, r)) = self.receivers.get(range.start) { - r.try_broadcast(msg.clone())?; + r.try_broadcast(msg)?; } else { println!("Unhandled message {:?}", core::any::type_name::()); } @@ -97,7 +96,7 @@ impl BusInner { } if let Some((_, r)) = self.receivers.get(range.start) { - r.broadcast(msg.clone()).await?; + r.broadcast(msg).await?; } else { println!("Unhandled message {:?}", core::any::type_name::()); }