internal FunctionRef AddFunctionRef(Action <IActorRef, object> tell, string suffix = "") { var r = GetRandomActorName("$$"); var n = string.IsNullOrEmpty(suffix) ? r : r + "-" + suffix; var childPath = new ChildActorPath(Self.Path, n, NewUid()); var functionRef = new FunctionRef(childPath, SystemImpl.Provider, SystemImpl.EventStream, tell); return(ImmutableInterlocked.GetOrAdd(ref _functionRefsDoNotCallMeDirectly, childPath.Name, functionRef)); }
internal bool RemoveFunctionRef(FunctionRef functionRef) { if (functionRef.Path.Parent != Self.Path) { throw new InvalidOperationException($"Trying to remove FunctionRef {functionRef.Path} from wrong ActorCell"); } var name = functionRef.Path.Name; if (ImmutableInterlocked.TryRemove(ref _functionRefsDoNotCallMeDirectly, name, out var fref)) { fref.Stop(); return(true); }
internal bool TryGetFunctionRef(string name, int uid, out FunctionRef functionRef) => FunctionRefs.TryGetValue(name, out functionRef) && (uid == ActorCell.UndefinedUid || uid == functionRef.Path.Uid);
internal bool TryGetFunctionRef(string name, out FunctionRef functionRef) => FunctionRefs.TryGetValue(name, out functionRef);