Beispiel #1
0
        private static ETTask <ActorMessageInfo> GetAsync(this MailBoxComponent self)
        {
            if (self.Queue.Count > 0)
            {
                return(ETTask.FromResult(self.Queue.Dequeue()));
            }

            self.Tcs = new ETTaskCompletionSource <ActorMessageInfo>();
            return(self.Tcs.Task);
        }
        private static ETTask <ActorTask> GetAsync(this ActorLocationSender self)
        {
            if (self.WaitingTasks.Count > 0)
            {
                ActorTask task = self.WaitingTasks.Peek();
                return(ETTask.FromResult(task));
            }

            self.Tcs = new ETTaskCompletionSource <ActorTask>();
            return(self.Tcs.Task);
        }
        public ETTask <KeyValuePair <RedisChannel, RedisValue> > Get(RedisEventSolverComponent self)
        {
            if (self.receivedQueue.TryDequeue(out var kp))
            {
                return(ETTask.FromResult(kp));
            }

            ETTaskCompletionSource <KeyValuePair <RedisChannel, RedisValue> > t = new ETTaskCompletionSource <KeyValuePair <RedisChannel, RedisValue> >();

            self.tcs = t;
            return(t.Task);
        }
Beispiel #4
0
        private static ETTask <bool> WaitLock(this LockComponent self)
        {
            if (self.status == LockStatus.Locked)
            {
                return(ETTask.FromResult(true));
            }

            ETTaskCompletionSource <bool> tcs = new ETTaskCompletionSource <bool>();

            self.queue.Enqueue(tcs);
            return(tcs.Task);
        }
Beispiel #5
0
        public static ETTask Lock(this MasterComponent self, IPEndPoint address)
        {
            if (self.lockedAddress == null)
            {
                self.lockedAddress = address;
                return(ETTask.FromResult(true));
            }

            ETTaskCompletionSource tcs = new ETTaskCompletionSource();
            LockInfo lockInfo          = new LockInfo(address, tcs);

            self.queue.Enqueue(lockInfo);
            return(tcs.Task);
        }