From 66b892572c253ed255c236b0ff02b45d9e2f4284 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Tue, 3 Apr 2018 09:18:22 -0700 Subject: [PATCH] Don't create a CommandExecutor if there are no observers. (#603) (#604) r=emily * Don't create a CommandExecutor if there are no observers. (#603) * Don't log if our executor channel goes away. This is routine. --- db/src/tx_observer.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/db/src/tx_observer.rs b/db/src/tx_observer.rs index 1b041e96..565a0736 100644 --- a/db/src/tx_observer.rs +++ b/db/src/tx_observer.rs @@ -132,6 +132,11 @@ impl TxObservationService { } pub fn in_progress_did_commit(&mut self, txes: IndexMap) { + // Don't spawn a thread only to say nothing. + if !self.has_observers() { + return; + } + let executor = self.executor.get_or_insert_with(|| { let (tx, rx): (Sender>, Receiver>) = channel(); let mut worker = CommandExecutor::new(rx); @@ -195,7 +200,10 @@ impl CommandExecutor { loop { match self.receiver.recv() { Err(RecvError) => { - eprintln!("Disconnected, terminating CommandExecutor"); + // "The recv operation can only fail if the sending half of a channel (or + // sync_channel) is disconnected, implying that no further messages will ever be + // received." + // No need to log here. return },