예제 #1
0
 public static void Add(this CoroutineLockQueue self, ETTask <CoroutineLock> tcs, int time)
 {
     self.queue.Enqueue(new CoroutineLockInfo()
     {
         Tcs = tcs, Time = time
     });
 }
예제 #2
0
        public static async ETTask <CoroutineLock> Wait(this CoroutineLockComponent self, int coroutineLockType, long key, int time = 60000)
        {
            CoroutineLockQueueType coroutineLockQueueType = self.list[coroutineLockType];

            CoroutineLockQueue queue = coroutineLockQueueType.GetChild <CoroutineLockQueue>(key);

            if (queue == null)
            {
                CoroutineLockQueue coroutineLockQueue = coroutineLockQueueType.AddChildWithId <CoroutineLockQueue>(key, true);
                return(self.CreateCoroutineLock(coroutineLockQueue, coroutineLockType, key, time, 1));
            }
            ETTask <CoroutineLock> tcs = ETTask <CoroutineLock> .Create(true);

            queue.Add(tcs, time);
            return(await tcs);
        }
예제 #3
0
        private static void Notify(this CoroutineLockComponent self, int coroutineLockType, long key, int level)
        {
            CoroutineLockQueueType coroutineLockQueueType = self.list[coroutineLockType];

            CoroutineLockQueue queue = coroutineLockQueueType.GetChild <CoroutineLockQueue>(key);

            if (queue == null)
            {
                return;
            }

            if (queue.Count == 0)
            {
                coroutineLockQueueType.RemoveChild(key);
                return;
            }

            CoroutineLockInfo coroutineLockInfo = queue.Dequeue();

            coroutineLockInfo.Tcs.SetResult(self.CreateCoroutineLock(queue, coroutineLockType, key, coroutineLockInfo.Time, level));
        }
예제 #4
0
 public static void Add(this CoroutineLockQueueType self, long key, CoroutineLockQueue value)
 {
     self.dictionary.Add(key, value);
 }
예제 #5
0
 public static bool TryGetValue(this CoroutineLockQueueType self, long key, out CoroutineLockQueue value)
 {
     return(self.dictionary.TryGetValue(key, out value));
 }
예제 #6
0
 public void Add(long key, CoroutineLockQueue coroutineLockQueue)
 {
     this.workQueues.Add(key, coroutineLockQueue);
     coroutineLockQueue.Parent = this;
 }
예제 #7
0
 public bool TryGetValue(long key, out CoroutineLockQueue coroutineLockQueue)
 {
     return(this.workQueues.TryGetValue(key, out coroutineLockQueue));
 }
예제 #8
0
        private static CoroutineLock CreateCoroutineLock(this CoroutineLockComponent self, CoroutineLockQueue coroutineLockQueue, int coroutineLockType, long key, int time, int level)
        {
            CoroutineLock coroutineLock = coroutineLockQueue.AddChildWithId <CoroutineLock, int, long, int>(++self.idGenerator, coroutineLockType, key, level, true);

            if (time > 0)
            {
                self.AddTimer(TimeHelper.ClientFrameTime() + time, coroutineLock);
            }
            return(coroutineLock);
        }
예제 #9
0
 public static CoroutineLockInfo Dequeue(this CoroutineLockQueue self)
 {
     return(self.queue.Dequeue());
 }
 private void RecycleCoroutineLockQueue(CoroutineLockQueue coroutineLockQueue)
 {
     this.coroutineLockQueuePool.Enqueue(coroutineLockQueue);
 }
예제 #11
0
 public void Add(long key, CoroutineLockQueue value)
 {
     this.dictionary.Add(key, value);
 }
예제 #12
0
 public bool TryGetValue(long key, out CoroutineLockQueue value)
 {
     return(this.dictionary.TryGetValue(key, out value));
 }