NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ReaderWriterLock Reference

public class ReaderWriterLock
{
  public ReaderWriterLock()
  public bool IsReaderLockHeld {get;}
  public bool IsWriterLockHeld {get;}
  public int WriterSeqNum {get;}
  public void AcquireReaderLock(int millisecondsTimeout);
  public void AcquireReaderLock(TimeSpan timeout)
  public void AcquireWriterLock(int millisecondsTimeout);
  public void AcquireWriterLock(TimeSpan timeout)
  public void ReleaseReaderLock();
  public void ReleaseWriterLock();
  public LockCookie UpgradeToWriterLock(int millisecondsTimeout);
  public LockCookie UpgradeToWriterLock(TimeSpan timeout)
  public void DowngradeFromWriterLock(ref LockCookie lockCookie);
  public LockCookie ReleaseLock();
  public void RestoreLock(ref LockCookie lockCookie);
  public bool AnyWritersSince(int seqNum);
}

ReaderWriterLock

Constructor

IsReaderLockHeld

Property that returns TRUE if the reader lock is held by the current thread

IsWriterLockHeld

Property that returns TRUE if the writer lock is held by the current thread

WriterSeqNum

Property that returns the current writer sequence number. The caller should be a reader or writer for getting meaningful results

AcquireReaderLock

Acquires reader lock. The thread will block if a different thread has writer lock.

AcquireWriterLock

Acquires writer lock. The thread will block if a different thread has reader lock. It will dead lock if this thread has reader lock. Use UpgardeToWriterLock when you are not sure if the thread has reader lock

ReleaseReaderLock

Releases reader lock.

ReleaseWriterLock

Releases writer lock.

UpgradeToWriterLock

Upgrades the thread to a writer. If the thread has is a reader, it is possible that the reader lock was released before writer lock was acquired.

DowngradeFromWriterLock

Restores the lock status of the thread to the one it was in when it called UpgradeToWriterLock.

ReleaseLock

Releases the lock irrespective of the number of times the thread

acquired the lock

RestoreLock

Restores the lock status of the thread to the one it was in when it called ReleaseLock.

AnyWritersSince

Returns true if there were intermediate writes since the sequence number was obtained. The caller should be a reader or writer for getting meaningful results