File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -6,34 +6,46 @@ namespace NHibernate.Cache
66{
77 class SyncCacheLock : ICacheLock
88 {
9+ private readonly MonitorLock _monitorLock ;
10+
911 class MonitorLock : IDisposable
1012 {
1113 private readonly object _lockObj ;
1214
1315 public MonitorLock ( object lockObj )
1416 {
15- Monitor . Enter ( lockObj ) ;
1617 _lockObj = lockObj ;
1718 }
1819
20+ public IDisposable Lock ( )
21+ {
22+ Monitor . Enter ( _lockObj ) ;
23+ return this ;
24+ }
25+
1926 public void Dispose ( )
2027 {
2128 Monitor . Exit ( _lockObj ) ;
2229 }
2330 }
2431
32+ public SyncCacheLock ( )
33+ {
34+ _monitorLock = new MonitorLock ( this ) ;
35+ }
36+
2537 public void Dispose ( )
2638 {
2739 }
2840
2941 public IDisposable ReadLock ( )
3042 {
31- return new MonitorLock ( this ) ;
43+ return _monitorLock . Lock ( ) ;
3244 }
3345
3446 public IDisposable WriteLock ( )
3547 {
36- return new MonitorLock ( this ) ;
48+ return _monitorLock . Lock ( ) ;
3749 }
3850
3951 public Task < IDisposable > ReadLockAsync ( )
You can’t perform that action at this time.
0 commit comments