/// <summary> /// Initializes a new instance of the <see cref="Repository"/> class. /// </summary> /// <param name="localPath"></param> /// <param name="container"></param> public Repository(NPath localPath, ICacheContainer container) { Guard.ArgumentNotNull(localPath, nameof(localPath)); LocalPath = localPath; cacheUpdateEvents = new Dictionary <CacheType, Action <CacheUpdateEvent> > { { CacheType.Branches, cacheUpdateEvent => { LocalBranchListChanged?.Invoke(cacheUpdateEvent); RemoteBranchListChanged?.Invoke(cacheUpdateEvent); LocalAndRemoteBranchListChanged?.Invoke(cacheUpdateEvent); } }, { CacheType.GitAheadBehind, c => TrackingStatusChanged?.Invoke(c) }, { CacheType.GitLocks, c => LocksChanged?.Invoke(c) }, { CacheType.GitLog, c => LogChanged?.Invoke(c) }, { CacheType.GitStatus, c => StatusEntriesChanged?.Invoke(c) }, { CacheType.GitUser, cacheUpdateEvent => { } }, { CacheType.RepositoryInfo, cacheUpdateEvent => { CurrentBranchChanged?.Invoke(cacheUpdateEvent); CurrentRemoteChanged?.Invoke(cacheUpdateEvent); CurrentBranchAndRemoteChanged?.Invoke(cacheUpdateEvent); } }, }; cacheContainer = container; cacheContainer.CacheInvalidated += CacheHasBeenInvalidated; cacheContainer.CacheUpdated += (cacheType, offset) => { cacheUpdateEvents[cacheType](new CacheUpdateEvent(cacheType, offset)); }; }
public void Release(Lock lockToRelease) { locks.Remove(lockToRelease); LocksChanged?.Invoke(this, null); if (!ResolvingDeadlock) { CheckLocks(); } }
public void Request(int id, bool shared, Action <Lock> onOK, Transação owner) { var nLock = new Lock(id, shared, onOK, this, owner); locks.Add(nLock); owner.Locks.Add(nLock); LocksChanged?.Invoke(this, null); CheckLocks(); }
private void CheckLocks() { var executadas = locks.FindAll(lck => lck.Executed); foreach (var nãoExecutada in locks.FindAll(lck => !lck.Executed)) { nãoExecutada.Owner.Waiting.Clear(); foreach (var mesmaID in executadas.FindAll(lck => lck.Id == nãoExecutada.Id && lck.Owner != nãoExecutada.Owner)) { if (!nãoExecutada.Shared || !mesmaID.Shared) { nãoExecutada.Owner.Waiting.Add(mesmaID); } } if (nãoExecutada.Owner.Waiting.Count == 0) { nãoExecutada.Executar(); LocksChanged?.Invoke(this, null); CheckLocks(); return; } } LocksChanged?.Invoke(this, null); try { foreach (var lck in locks.FindAll(lck => !lck.Executed)) { CheckForDeadlocks(lck, lck, null); } }catch (DeadlockException ex) { ResolvingDeadlock = true; new DeadlockWindow(ex).ShowDialog(); ResolvingDeadlock = false; CheckLocks(); return; } }
private void HandleGitLocksCacheUpdatedEvent(CacheUpdateEvent cacheUpdateEvent) { Logger.Trace("GitLocksCache Updated {0}", cacheUpdateEvent.UpdatedTimeString); LocksChanged?.Invoke(cacheUpdateEvent); }