Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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);
            }
Esempio n. 3
0
 internal bool TryGetFunctionRef(string name, int uid, out FunctionRef functionRef) =>
 FunctionRefs.TryGetValue(name, out functionRef) && (uid == ActorCell.UndefinedUid || uid == functionRef.Path.Uid);
Esempio n. 4
0
 internal bool TryGetFunctionRef(string name, out FunctionRef functionRef) =>
 FunctionRefs.TryGetValue(name, out functionRef);