From 42c361f7ee75a2c9bf41fabfebed7910fb701d83 Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Mon, 2 Sep 2024 12:58:47 -0400 Subject: [PATCH] update comment about keeping promise imports alive --- capnp-rpc/src/rpc.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/capnp-rpc/src/rpc.rs b/capnp-rpc/src/rpc.rs index 63a20213f..3cb581579 100644 --- a/capnp-rpc/src/rpc.rs +++ b/capnp-rpc/src/rpc.rs @@ -1488,9 +1488,14 @@ impl ConnectionState { let client: Box> = Box::new(import_client.into()); let client: Box = client; - // XXX do I need something like this? - // Make sure the import is not destroyed while this promise exists. - // let promise = promise.attach(client.add_ref()); + // Here the C++ implementation does something like: + // ``` + // // Make sure the import is not destroyed while this promise exists. + // let promise = promise.attach(client.add_ref()); + // ``` + // However, as far as I can tell that is unnecessary, because the + // PromiseClient holds `client` until it resolves, after which point + // there is no reason to keep the import alive. let client = PromiseClient::new(&connection_state, client, Some(import_id));