Jelajahi Sumber

Add a comment explain why stop_wait_group cannot be merged into DaemonEnv.

Jing Yang 4 tahun lalu
induk
melakukan
80487fdc85
1 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 7 0
      src/lib.rs

+ 7 - 0
src/lib.rs

@@ -265,6 +265,13 @@ where
         self.new_log_entry.take().map(|n| n.send(None));
         self.apply_command_signal.notify_all();
         self.snapshot_daemon.kill();
+        // We cannot easily combine stop_wait_group into DaemonEnv because of
+        // shutdown dependencies. The thread pool is not managed by DaemonEnv,
+        // but it cannot be shutdown until all daemons are. On the other hand
+        // the thread pool uses DaemonEnv, thus must be shutdown before
+        // DaemonEnv. The shutdown sequence is stop_wait_group -> thread_pool
+        // -> DaemonEnv. The first and third cannot be combined with the second
+        // in the middle.
         self.stop_wait_group.wait();
         std::sync::Arc::try_unwrap(self.thread_pool)
             .expect(