示例#1
0
文件: Actor.cs 项目: luyikk/NetX
        public void Action(long id, int cmd, OpenAccess access, params object[] args)
        {
            if (status == Disposed)
            {
                throw new ObjectDisposedException("this actor is dispose");
            }

            if (maxQueuelen > 0)
            {
                if (ActorRunQueue.Count > maxQueuelen)
                {
                    throw new NetxException($"this actor queue count >{maxQueuelen}", ErrorType.ActorQueueMaxErr);
                }
            }

            var sa = new ActorMessage <object>(id, cmd, access, args);

            ActorRunQueue.Enqueue(sa);

            try
            {
                Runing().Wait();
            }
            catch (Exception er)
            {
                Log.Error(er);
            }
        }
示例#2
0
文件: Actor.cs 项目: luyikk/NetX
        public ValueTask <T> AsyncFunc <T>(long id, int cmd, OpenAccess access, params object[] args)
        {
            if (status == Disposed)
            {
                throw new ObjectDisposedException("this actor is dispose");
            }

            if (maxQueuelen > 0)
            {
                if (ActorRunQueue.Count > maxQueuelen)
                {
                    throw new NetxException($"this actor queue count >{maxQueuelen}", ErrorType.ActorQueueMaxErr);
                }
            }

            var sa = new ActorMessage <T>(id, cmd, access, args);

            ActorRunQueue.Enqueue(sa);
            Runing().Wait();
            return(sa.Awaiter);
        }