Click or drag to resize

ReaderWriterSpinLock Class

Represents a fast, lightweight reader/writer lock that uses spinning to perform locking. No recursive acquires or upgradable locks are allowed (i.e., all entered locks must be exited before entering another lock).
Inheritance Hierarchy
SystemObject
  GSF.ThreadingReaderWriterSpinLock

Namespace: GSF.Threading
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.207-beta+1781b796b2aa7a54013a031eb432fe4ccee31867
Syntax
public class ReaderWriterSpinLock
View Source

The ReaderWriterSpinLock type exposes the following members.

Constructors
 NameDescription
Public methodReaderWriterSpinLockInitializes a new instance of the ReaderWriterSpinLock class
Top
Methods
 NameDescription
Public methodEnterReadLock Enters the lock in read mode.
Public methodEnterWriteLock Enters the lock in write mode.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodExitReadLock Exits read mode.
Public methodExitWriteLock Exits write mode.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
Remarks
This reader/writer lock uses SpinWait to spin the CPU instead of engaging event based locking. As a result it should only be used in cases where lock times are expected to be very small, reads are very frequent and writes are rare. If hold times for write locks can be lengthy, it will be better to use ReaderWriterLockSlim instead to avoid unnecessary CPU utilization due to spinning incurred by waiting reads.
See Also