Show / Hide Table of Contents

Struct ReaderWriterSpinLock

Represents lightweight reader-writer lock based on spin loop.

Inherited Members
ValueType.Equals(Object)
ValueType.GetHashCode()
ValueType.ToString()
Object.Equals(Object, Object)
Object.GetType()
Object.ReferenceEquals(Object, Object)
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public struct ReaderWriterSpinLock
Remarks

This type should not be used to synchronize access to the I/O intensive resources.

Properties

| Improve this Doc View Source

CurrentReadCount

Gets the total number of unique threads that have entered the lock in read mode.

Declaration
public int CurrentReadCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

IsReadLockHeld

Gets a value that indicates whether the current thread has entered the lock in read mode.

Declaration
public bool IsReadLockHeld { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

IsWriteLockHeld

Gets a value that indicates whether the current thread has entered the lock in write mode.

Declaration
public bool IsWriteLockHeld { get; }
Property Value
Type Description
Boolean

Methods

| Improve this Doc View Source

EnterReadLock()

Enters the lock in read mode.

Declaration
public void EnterReadLock()
| Improve this Doc View Source

EnterWriteLock()

Enters the lock in write mode.

Declaration
public void EnterWriteLock()
| Improve this Doc View Source

ExitReadLock()

Exits read mode.

Declaration
public void ExitReadLock()
| Improve this Doc View Source

ExitWriteLock()

Exits the write lock.

Declaration
public void ExitWriteLock()
| Improve this Doc View Source

TryEnterReadLock()

Attempts to enter reader lock without blocking the caller thread.

Declaration
public bool TryEnterReadLock()
Returns
Type Description
Boolean

true if reader lock is acquired; otherwise, false.

| Improve this Doc View Source

TryEnterReadLock(TimeSpan, CancellationToken)

Tries to enter the lock in read mode.

Declaration
public bool TryEnterReadLock(TimeSpan timeout, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
TimeSpan timeout

The interval to wait.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Boolean

true if the calling thread entered read mode, otherwise, false.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

TryEnterWriteLock()

Attempts to enter writer lock without blocking the caller thread.

Declaration
public bool TryEnterWriteLock()
Returns
Type Description
Boolean

true if writer lock is acquired; otherwise, false.

| Improve this Doc View Source

TryEnterWriteLock(TimeSpan, CancellationToken)

Tries to enter the lock in write mode.

Declaration
public bool TryEnterWriteLock(TimeSpan timeout, CancellationToken token = default(CancellationToken))
Parameters
Type Name Description
TimeSpan timeout

The interval to wait.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
Boolean

true if the calling thread entered read mode, otherwise, false.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

| Improve this Doc View Source

TryOptimisticRead()

Returns a stamp that can be validated later.

Declaration
public ReaderWriterSpinLock.LockStamp TryOptimisticRead()
Returns
Type Description
ReaderWriterSpinLock.LockStamp

Optimistic read stamp. May be invalid.

| Improve this Doc View Source

Validate(ReaderWriterSpinLock.LockStamp)

Returns true if the lock has not been exclusively acquired since issuance of the given stamp.

Declaration
public bool Validate(in ReaderWriterSpinLock.LockStamp stamp)
Parameters
Type Name Description
ReaderWriterSpinLock.LockStamp stamp

A stamp to check.

Returns
Type Description
Boolean

true if the lock has not been exclusively acquired since issuance of the given stamp; else false.

Extension Methods

Sequence.Skip<TEnumerator, T>(ref TEnumerator, Int32)
ExpressionBuilder.Const<T>(T)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX