Skip to content
Louis Thibault edited this page Jan 28, 2022 · 8 revisions

Rules for Ref Counting

  1. By default, the caller is responsible for calling Release() on a capability when finished.
  2. Calling foo.Bar(baz) where foo and baz are capabilities transfers ownership of foo to baz. The foo instance will call bar.Release() when finished.
  3. Capabilities received as arguments to an RPC handler are borrowed and will be released when the RPC handler returns. You may call AddRef() to persist a capability beyond the scope of the RPC handler, at which point Rule 1 applies.

Special Cases

  1. [ BUG ] Passing a capability to itself causes a deadlock.