here the data structure to maintain some states for resolver is used as a reference, but here the data structure to maintain inner states for proxy is used as a pointer, what’s the logic for u to decide when to use Reference and when to just use pointer?
is there anyone can help?
I didn’t stare at the code for long enough to be certain, but I don’t think
Resolver needs to be reference counted. We should be able to just replace
state Reference<Resolver> self(new Resolver(resolver.id(), initReq.commitProxyCount, initReq.resolverCount));
state Resolver self(resolver.id(), initReq.commitProxyCount, initReq.resolverCount);
Reference is used whenever object-ownership is shared across multiple actors. Otherwise using stack-allocated variables is usually faster. So it’s the same rule as for using
std::shared_ptr in standard C++,
Reference is just slightly more efficient at the cost of not supporting weak pointers.