HalfLock Class

Provides a light weight exclusive lock that is approximately 2.5 times faster than Monitor. WARNING: This lock should be used in a Using block, and duplicate calls to Lock without releasing will cause a deadlock.

Definition

Namespace: SnapDB.Threading
Assembly: SnapDB (in SnapDB.dll) Version: 1.0.102.0 -- Release Build+29075351d0e5aa4dea46a5c520805222f672dc2e
public class HalfLock
Inheritance
Object    HalfLock

Remarks

After writing this class I did some review of the methodology. Reviewing this article: http://www.adammil.net/blog/v111_Creating_High-Performance_Locks_and_Lock-free_Code_for_NET_.html Brings up stability issues with the lock. Namely what happens when unhandled exceptions occurs when acquiring and releasing the lock. I have intentionally left out any kind of protection against this as it severly reduces the speed of this code. Therefore do not use this locking method where a Thread.Abort() might be used as a control method.

Constructors

HalfLock Creates a TinyLock

Methods

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Lock Acquires an exclusive lock on this class. Place call in a using block. Duplicate calls to this within the same thread will cause a deadlock.
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ToStringReturns a string that represents the current object.
(Inherited from Object)

See Also