public override void Dispose() { if (this.IsDisposed) { return; } base.Dispose(); this.CoroutineLock.Dispose(); this.CoroutineLock = null; LockInstanceId = 0; }
public async void Lock(long key, long instanceId, int time = 0) { CoroutineLock coroutineLock = await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Location, key); LockInfo lockInfo = EntityFactory.Create <LockInfo, long, CoroutineLock>(this.Domain, instanceId, coroutineLock); lockInfo.Parent = this; this.lockInfos.Add(key, lockInfo); Log.Info($"location lock key: {key} instanceId: {instanceId}"); if (time > 0) { long lockInfoInstanceId = lockInfo.InstanceId; await TimerComponent.Instance.WaitAsync(time); if (lockInfo.InstanceId != lockInfoInstanceId) { return; } UnLock(key, instanceId, instanceId); } }