Click or drag to resize

SlimLock Class

: a simple spinLock algorithm. The spinLock will attempt to exchange a value atomically. If the exchange can not be done then the spinLock will enter a loop for a maximum amount of time as specified. In the loop it will use a spinWait to allow the CPU to idle for a few cycles in an attempt to wait for the resource to be freed up. If after a number of attempts the resource has not been freed, the spinLock will give up its quanta using a sleep. The sleep will force the thread to yield and if all goes well releases the thread (which may be on the same processor) to release the critical resource. There's no reason to use this as a general purpose lock, monitors do just fine.
Inheritance Hierarchy
SystemObject
  com.espertech.esper.compat.threading.locksSlimLock

Namespace:  com.espertech.esper.compat.threading.locks
Assembly:  NEsper.Compat (in NEsper.Compat.dll) Version: 8.0.0.0
Syntax
C#
public sealed class SlimLock

The SlimLock type exposes the following members.

Constructors
  NameDescription
Public methodSlimLock
Initializes a new instance of the SlimLock class
Top
Methods
  NameDescription
Public methodEnter
Acquires the lock. If the lock can be acquired immediately it does so. In the event that the lock can not be acquired the lock will use a spin-lock algorithm to acquire the lock.
Public methodEnter(Int32)
Acquires the lock. If the lock can be acquired immediately it does so. In the event that the lock can not be acquired the lock will use a spin-lock algorithm to acquire the lock.
Public methodRelease
Releases the lock, allowing waiters to proceed.
Public methodStatic memberSmartWait(Int32)
Public methodStatic memberSmartWait(Int32, Int64)
Top
Fields
  NameDescription
Public fieldStatic memberIsMultiProcessor
Top
See Also