Esempio n. 1
0
        public TrackedLock(TrackedLockCollection collection, Func <string> getName = null)
        {
            Collection = collection;
            GetName    = getName;

            collection.Track(this);
        }
Esempio n. 2
0
            public Wait (TrackedLockCollection collection, TrackedLock lck, Thread thread) {
                Collection = collection;
                Lock = lck;
                Thread = thread;

                if (!Collection.WaitsByThread.TryAdd(thread, this))
                    throw new ThreadStateException();
            }
Esempio n. 3
0
            public Wait(TrackedLockCollection collection, TrackedLock lck, Thread thread)
            {
                Collection = collection;
                Lock       = lck;
                Thread     = thread;

                if (!Collection.WaitsByThread.TryAdd(thread, this))
                {
                    throw new ThreadStateException();
                }
            }
Esempio n. 4
0
            public Entry (QualifiedMemberIdentifier identifier, TrackedLockCollection lockCollection) {
                Identifier = identifier;

                StaticAnalysisDataLock = new TrackedLock(lockCollection, () => String.Format("{0}", this.Identifier.ToString()));
            }
Esempio n. 5
0
 public TrackedLock(TrackedLockCollection collection, string name)
     : this(collection, () => name)
 {
 }
Esempio n. 6
0
 public TrackedLock(TrackedLockCollection collection, Func <string> getName = null)
 {
     Collection = collection;
     GetName    = getName;
     WeakSelf   = new WeakTrackedLockReference(this);
 }
Esempio n. 7
0
        public TrackedLockResult TryBlockingEnter (out TrackedLockCollection.DeadlockInfo deadlock, bool recursive = false, int timeoutMs = -1) {
            bool iterating = true;
            TrackedLockCollection.Wait wait;
            deadlock = null;

            while (iterating) {
                var result = TryEnter(recursive);
                if (result.FailureReason != TrackedLockFailureReason.HeldByOtherThread)
                    return result;

                EnsureTracked();

                if (Collection.TryCreateWait(WeakSelf, out deadlock, out wait)) {
                    using (wait) {
                        result = TryEnter(recursive);

                        if (result.FailureReason == TrackedLockFailureReason.HeldByOtherThread) {
                            var finishedWaiting = wait.Block(timeoutMs);

                            if (!finishedWaiting)
                                iterating = false;
                        } else {
                            return result;
                        }
                    }
                } else {
                    return new TrackedLockResult(TrackedLockFailureReason.Deadlock);
                }
            }

            return new TrackedLockResult(TrackedLockFailureReason.HeldByOtherThread);
        }
Esempio n. 8
0
 public TrackedLock (TrackedLockCollection collection, Func<string> getName = null) {
     Collection = collection;
     GetName = getName;
     WeakSelf = new WeakTrackedLockReference(this);
 }
Esempio n. 9
0
 public TrackedLock (TrackedLockCollection collection, string name)
     : this(collection, () => name) {
 }