public static void Add(this CoroutineLockQueue self, ETTask <CoroutineLock> tcs, int time) { self.queue.Enqueue(new CoroutineLockInfo() { Tcs = tcs, Time = time }); }
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); }
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)); }
public static void Add(this CoroutineLockQueueType self, long key, CoroutineLockQueue value) { self.dictionary.Add(key, value); }
public static bool TryGetValue(this CoroutineLockQueueType self, long key, out CoroutineLockQueue value) { return(self.dictionary.TryGetValue(key, out value)); }
public void Add(long key, CoroutineLockQueue coroutineLockQueue) { this.workQueues.Add(key, coroutineLockQueue); coroutineLockQueue.Parent = this; }
public bool TryGetValue(long key, out CoroutineLockQueue coroutineLockQueue) { return(this.workQueues.TryGetValue(key, out coroutineLockQueue)); }
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); }
public static CoroutineLockInfo Dequeue(this CoroutineLockQueue self) { return(self.queue.Dequeue()); }
private void RecycleCoroutineLockQueue(CoroutineLockQueue coroutineLockQueue) { this.coroutineLockQueuePool.Enqueue(coroutineLockQueue); }
public void Add(long key, CoroutineLockQueue value) { this.dictionary.Add(key, value); }
public bool TryGetValue(long key, out CoroutineLockQueue value) { return(this.dictionary.TryGetValue(key, out value)); }