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

            collection.Track(this);
        }
Example #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();
            }
Example #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();
                }
            }
Example #4
0
            public Entry (QualifiedMemberIdentifier identifier, TrackedLockCollection lockCollection) {
                Identifier = identifier;

                StaticAnalysisDataLock = new TrackedLock(lockCollection, () => String.Format("{0}", this.Identifier.ToString()));
            }
Example #5
0
 public TrackedLock(TrackedLockCollection collection, string name)
     : this(collection, () => name)
 {
 }
Example #6
0
 public TrackedLock(TrackedLockCollection collection, Func <string> getName = null)
 {
     Collection = collection;
     GetName    = getName;
     WeakSelf   = new WeakTrackedLockReference(this);
 }
Example #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);
        }
Example #8
0
 public TrackedLock (TrackedLockCollection collection, Func<string> getName = null) {
     Collection = collection;
     GetName = getName;
     WeakSelf = new WeakTrackedLockReference(this);
 }
Example #9
0
 public TrackedLock (TrackedLockCollection collection, string name)
     : this(collection, () => name) {
 }