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

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

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