public static async ETTask <CoroutineLock> Wait(this CoroutineLockComponent self, int coroutineLockType, long key, int time = 60000) { CoroutineLockQueueType coroutineLockQueueType = self.list[coroutineLockType]; if (!coroutineLockQueueType.TryGetValue(key, out CoroutineLockQueue queue)) { coroutineLockQueueType.Add(key, self.AddChildWithId <CoroutineLockQueue>(++self.idGenerator, true)); return(self.CreateCoroutineLock(coroutineLockType, key, time, 1)); } ETTask <CoroutineLock> tcs = ETTask <CoroutineLock> .Create(true); queue.Add(tcs, time); return(await tcs); }
public async ETTask <CoroutineLock> Wait(CoroutineLockType coroutineLockType, long key) { CoroutineLockQueueType coroutineLockQueueType = this.list[(int)coroutineLockType]; if (!coroutineLockQueueType.TryGetValue(key, out CoroutineLockQueue queue)) { queue = EntityFactory.Create <CoroutineLockQueue>(this.Domain); coroutineLockQueueType.Add(key, queue); return(EntityFactory.CreateWithParent <CoroutineLock, CoroutineLockType, long>(this, coroutineLockType, key)); } ETTaskCompletionSource <CoroutineLock> tcs = new ETTaskCompletionSource <CoroutineLock>(); queue.Enqueue(tcs); return(await tcs.Task); }