Hi Brano, To accomplish this, you'll need to write a "Server" object that holds a weak reference to the real server, and which starts throwing exceptions when the weak reference becomes null. Sorry, Cap'n Proto doesn't have any built-in support for this.
I occasionally contemplate how we might go about introducing a notion of ownership into Cap'n Proto capabilities, but each time I try it seems to get hopelessly awkward. I may think about it more in the future, but moving away from refcounting would be a pretty major change. -Kenton On Fri, Jun 17, 2016 at 1:43 PM, Branislav Katreniak <[email protected]> wrote: > > I try to model real word objects as capnp Server instances, but the > reference counted approach goes against me. AFAIK the only way to create > local Client instance from Server instance is to initialize client with > kj::Own<Server>. The server instance then lives as long as the last client > goes out of scope. > > I need the Server instance to live as long (and no longer) as the real > world object lives. I would like to own the Server instance in application > code, Clients being weak pointers to Server instance. When Server instance > is deleted, clients will fail pretty much like when the connection between > Client and Server permanently breaks. > > Does this concept exist in capnp? > > Kind regards > Brano > > -- > You received this message because you are subscribed to the Google Groups > "Cap'n Proto" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > Visit this group at https://groups.google.com/group/capnproto. > -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/capnproto.
