//
using System.Collections;
+using System.Runtime.InteropServices;
+using System.Runtime.ConstrainedExecution;
+
namespace System.Threading
{
- public sealed class ReaderWriterLock
+ [ComVisible (true)]
+ public sealed class ReaderWriterLock: CriticalFinalizerObject
{
private int seq_num = 1;
private int state;
{
writer_queue = new LockQueue (this);
reader_locks = new Hashtable ();
+
+ GC.SuppressFinalize (this);
+ }
+
+ ~ReaderWriterLock ()
+ {
}
public bool IsReaderLockHeld {
+ [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
get {
lock (this) return reader_locks.ContainsKey (Thread.CurrentThreadId);
}
}
public bool IsWriterLockHeld {
+ [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
get {
lock (this) return (state < 0 && Thread.CurrentThreadId == writer_lock_owner);
}
return cookie;
}
+ [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
public void ReleaseReaderLock()
{
lock (this) {
writer_queue.Pulse ();
}
+ [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
public void ReleaseWriterLock()
{
lock (this) {