Пример #1
0
        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
        private async Task <object?> Call_runing(ActorMessage result)
        {
            var cmd  = result.Cmd;
            var args = result.Args;


            #region Awaken and sleep

            if (cmd == SleepCmd)
            {
                await ActorController.Sleeping();

                IsSleep = true;
                return(default);
Пример #3
0
        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);
        }