Ejemplo n.º 1
0
 public void Release(Lock lockToRelease)
 {
     locks.Remove(lockToRelease);
     LocksChanged?.Invoke(this, null);
     if (!ResolvingDeadlock)
     {
         CheckLocks();
     }
 }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
 private void HandleGitLocksCacheUpdatedEvent(CacheUpdateEvent cacheUpdateEvent)
 {
     Logger.Trace("GitLocksCache Updated {0}", cacheUpdateEvent.UpdatedTimeString);
     LocksChanged?.Invoke(cacheUpdateEvent);
 }