Selaa lähdekoodia

Add a comment to explain the lifetime of a parameter.

Jing Yang 4 vuotta sitten
vanhempi
commit
b7d0475f38
1 muutettua tiedostoa jossa 6 lisäystä ja 0 poistoa
  1. 6 0
      src/heartbeats.rs

+ 6 - 0
src/heartbeats.rs

@@ -78,6 +78,12 @@ where
 
     const HEARTBEAT_RETRY: usize = 1;
     async fn send_heartbeat(
+        // Here rpc_client must be owned by the returned future. The returned
+        // future is scheduled to run on a thread pool. We do not control when
+        // the future will be run, or when it will be done with the RPC client.
+        // If a reference is passed in, the reference essentially has to be a
+        // static one, i.e. lives forever. Thus we chose to let the future own
+        // the RPC client.
         rpc_client: impl RemoteRaft<Command>,
         args: AppendEntriesArgs<Command>,
         term_watermark: TermMarker<Command>,