-
-
Notifications
You must be signed in to change notification settings - Fork 118
Ref Counting
Ian Denhardt edited this page Jan 28, 2022
·
8 revisions
- Each reference to a capability has an "owner." The owner is responsible for calling
.Release()on the reference when it is no longer needed. - Generated
Foo_ServerToClientmethods return a capability referenced owned by the caller. - The
.AddRef()method returns a new reference to the same underlying capability, which is owned by the caller. - Calling
foo.Bar(baz)wherefooandbazare capabilities transfers ownership ofbaztofoo. Thefooinstance will callbaz.Release()when finished. - Capabilities received as arguments to an RPC handler are borrowed and will be released when the RPC handler returns. Calling
AddRef()returns a capability (owned by the caller) that may persist beyond the scope of the RPC handler, per rule 3.
- [ BUG ] Passing the last reference for a capability to itself causes a deadlock.