Freigeben über


AsyncReaderWriterLock Class

Microsoft internal only. A non-blocking lock that allows concurrent access, exclusive access, or concurrent access that can be upgraded to exclusive access.

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Threading.AsyncReaderWriterLock
    Microsoft.VisualStudio.Threading.AsyncReaderWriterResourceLock<TMoniker, TResource>

Namespace:  Microsoft.VisualStudio.Threading
Assembly:  Microsoft.VisualStudio.Threading (in Microsoft.VisualStudio.Threading.dll)

Syntax

'Declaration
Public Class AsyncReaderWriterLock _
    Implements IHangReportContributor
public class AsyncReaderWriterLock : IHangReportContributor
public ref class AsyncReaderWriterLock : IHangReportContributor
type AsyncReaderWriterLock =  
    class 
        interface IHangReportContributor 
    end
public class AsyncReaderWriterLock implements IHangReportContributor

The AsyncReaderWriterLock type exposes the following members.

Constructors

  Name Description
Public method AsyncReaderWriterLock() Microsoft internal only. Initializes a new instance of AsyncReaderWriterLock.
Public method AsyncReaderWriterLock(Boolean) Microsoft internal only. Initializes a new instance of syncReaderWriterLock, specifying whether to spend additional resources on diagnostic details.

Top

Properties

  Name Description
Protected property AmbientLock Microsoft internal only. Gets the lock held by the caller's execution context.
Protected property CaptureDiagnostics Microsoft internal only. Determines whether additional resources should be spent to collect information that would be useful in diagnosing deadlocks.
Public property Completion Microsoft internal only. Gets a task whose completion signals that this lock will no longer issue locks.
Public property IsAnyLockHeld Microsoft internal only. Determines whether any kind of lock is held by the caller and can be immediately used given the caller's context.
Public property IsAnyPassiveLockHeld Microsoft internal only. Determines whether any kind of lock is held by the caller without regard to the lock compatibility of the caller's context.
Public property IsPassiveReadLockHeld Determines whether a read lock is held by the caller without regard to the lock compatibility of the caller's context.
Public property IsPassiveUpgradeableReadLockHeld Determines whether an upgradeable read lock is held by the caller without regard to the lock compatibility of the caller's context.
Public property IsPassiveWriteLockHeld Determines whether a write lock is held by the caller without regard to the lock compatibility of the caller's context.
Public property IsReadLockHeld Microsoft internal only. Determines whether the caller holds a read lock.
Public property IsUpgradeableReadLockHeld Microsoft internal only. Determines whether the caller holds an upgradeable read lock.
Public property IsWriteLockHeld Microsoft internal only. Determines whether the caller holds a write lock.
Protected property SyncObject Microsoft internal only. Gets the object used to synchronize access to the fields of this instance.

Top

Methods

  Name Description
Public method Complete Microsoft internal only. Causes new top-level lock requests to be rejected and the Completion task to transition to a completed state after any issued locks have been released.
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Protected method GetAggregateLockFlags Microsoft internal only. Gets the aggregate of the lock flags for all nested locks.
Public method GetHashCode Serves as the default hash function. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method HideLocks Microsoft internal only. Prevents use or visibility of the caller's lock(s) until the returned value is disposed.
Protected method LockStackContains Microsoft internal only. Checks whether the aggregated flags from all the locks in the lock stack satisfy the specified flag(s).
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnBeforeExclusiveLockReleasedAsync Microsoft internal only. Occurs when the last write lock is about to be released.
Protected method OnBeforeLockReleasedAsync Microsoft internal only. Occurs when any lock is being released.
Public method OnBeforeWriteLockReleased Microsoft internal only. Registers a callback that is invoked when the outermost write lock held by the caller is about to be released.
Protected method OnCriticalFailure(Exception) Occurs when the lock detects an internal error or illegal usage pattern that indicates a serious flaw that should be immediately reported to the application, while possibly also stopping the process to avoid hangs or data corruption.
Protected method OnCriticalFailure(String) Occurs when the lock detects an internal error or illegal usage pattern that indicates a serious flaw that should be immediately reported to the application, while possibly also stopping the process to avoid hangs or data corruption.
Protected method OnExclusiveLockReleasedAsync Microsoft internal only. Occurs after an exclusive lock is released but before any other lock consumer has a chance to enter the lock.
Protected method OnUpgradeableReadLockReleased Microsoft internal only. Occurs when a top-level upgradeable read lock is released, leaving no remaining (write) lock.
Public method ReadLockAsync Microsoft internal only. Gets a read lock, asynchronously awaiting for the lock if it is not immediately available.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method UpgradeableReadLockAsync(CancellationToken) Microsoft internal only. Gets a read lock, asynchronously awaiting for the lock if it is not immediately available.
Public method UpgradeableReadLockAsync(AsyncReaderWriterLock.LockFlags, CancellationToken) Microsoft internal only. Gets a read lock, asynchronously awaiting for the lock if it is not immediately available.
Public method WriteLockAsync(CancellationToken) Microsoft internal only. Gets a write lock, asynchronously awaiting for the lock if it is not immediately available.
Public method WriteLockAsync(AsyncReaderWriterLock.LockFlags, CancellationToken) Microsoft internal only. Gets a write lock, asynchronously awaiting for the lock if it is not immediately available.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IHangReportContributor.GetHangReport Microsoft internal only. data for a hang report.

Top

Remarks

This class is a custom awaitable rather than a Task{LockReleaser}, because it is necessary to set CallContext data in the context of the entity receiving the lock. To do this the code must be executed at the start of the continuation (whether or not it yields).

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Threading Namespace