Project Description
ReaderWriterLocker which cannot be hard locked. Meant to replace ReaderWriterLock and ReaderWriterLockSlim.  Another feature is that you don't have to be bothered by using upgrade locks.  These are done automatically.

Forked from jpmikkers' ReaderWriterLockAlt located at http://readerwriterlockalt.codeplex.com/.  If you would like to learn how to design your own, or you would like to help with this project, please start there.

It supports .NET 2.0+.  And in the future, this code will be provided in VB.net, C# .net, and pending library selection, gnu gcc C++.

If you would like regular locking (replacing SyncLocks/locks) that cannot be hard locked, simply use this class and only use write locks.

License
This project uses a new Tri-License Choice MIT/L-GPL/MS-PL.  As such, you have a choice of choosing MIT, L-GPL v2 or v3, or MS-PL. Or you can choose to use the tri-license and let others have their choice. While using this tri-license, MIT will be used in regards to the code, and L-GPL v2 for patents (so algorithms remain open source).  Only when MS-PL is chosen, does it apply (dropping MIT and L-GPL).

Problem Solved
The typical lock(A) locking on lock(B), and lock(B) locking on lock(A). I detect when it happens, and let one thread "run its course" to solve this issue.

ReaderWriteLocker Lock = New ReadWriteLocker(True);

using (IDisposable ReadLock = Lock.GetReadLock())
{
  ' Perform any reading you might need, like iterating through a List.

  using (IDisposable WriteLock = Lock.GetWriteLock())
  {
    ' Perform any writing you may need, like adding items to a List.

  } // End using
} // End using

Dim Lock As ReadWriteLocker(True)

Using ReadLock As IDisposable = Lock.GetReadLock()
  ' Perform any reading you might need, like iterating through a List.

  Using WriteLock As IDisposable = Lock.GetWriteLock()
    ' Perform any writing you may need, like adding items to that List.

  End Using
End Using


Last edited Sep 16, 2010 at 4:56 AM by TamusJRoyce, version 23