Пример #1
0
            internal PipLock(LockManager owner, PipId pipId1, PipId pipId2, object accessVerifier)
            {
                Contract.Requires(owner != null);
                Contract.Requires(pipId1.IsValid);
                Contract.Assert(owner.m_accessVerifier == accessVerifier, "PipLocks can only be created by a parent LockManager");

                m_owner = owner;
#if DEBUG
                m_owner.m_outstandingNonGlobalLocks.Value = m_owner.m_outstandingNonGlobalLocks.Value + 1;
#endif

                // Try to acquire the global shared lock
                m_globalSharedLock = owner.AcquireGlobalSharedLockIfApplicable();

                m_minScope = owner.m_scopedPipLockMap.OpenScope(pipId1);
                m_minScope.Value.EnterWriteLock();

                // Second pip id may be invalid if this is only being used to lock a single pip
                if (pipId2.IsValid)
                {
                    m_maxScope = owner.m_scopedPipLockMap.OpenScope(pipId2);
                    m_maxScope.Value.EnterWriteLock();
                }
                else
                {
                    m_maxScope = default(ScopedReferenceMap <PipId, ReadWriteLock> .Scope);
                }
            }