public void Dispose() { foreach (var item in ActorCollect) { item.Value.Dispose(); } ActorCollect.Clear(); }
public ValueTask AsyncAction(long id, int cmd, OpenAccess access, params object[] args) { if (ActorCollect.TryGetValue(cmd, out Actor m)) { return(m.AsyncAction(id, cmd, access, args)); } else { throw new NetxException($"not found actor service cmd:{cmd}", ErrorType.ActorErr); } }
public void SyncAction(long id, int cmd, OpenAccess access, params object[] args) { if (ActorCollect.ContainsKey(cmd)) { ActorCollect[cmd].Action(id, cmd, access, args); } else { Log.ErrorFormat("not found actor service cmd:{cmd}", cmd); } }
public MethodRegister?GetCmdService(int cmd) { if (ActorCollect.ContainsKey(cmd)) { return(ActorCollect[cmd].CmdDict[cmd]); } else { return(null); } }
public LambdaActorRun(string key, IServiceProvider container, LambdaController lambdaController) : base(container, container.GetRequiredService <ILoggerFactory>().CreateLogger("LambdaActorRun->")) { Key = key; actorCollect = new Lazy <ConcurrentDictionary <int, Actor> >(); var actor = new Actor(Container, this, ActorScheduler, lambdaController); actor.CompletedEvent += Actor_CompletedEvent; foreach (int cmd in actor.CmdDict.Keys) { ActorCollect.AddOrUpdate(cmd, actor, (a, b) => actor); } if (ActorCollect.Count > 0) { Task.Factory.StartNew(SleepingHandler); } foreach (var @event in container.GetServices <ActorEventBase>()) { this.CompletedEvent += @event.ActorEventCompleted; } }