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
6
6
{
7
7
class SyncCacheLock : ICacheLock
8
8
{
9
+ private readonly MonitorLock _monitorLock ;
10
+
9
11
class MonitorLock : IDisposable
10
12
{
11
13
private readonly object _lockObj ;
12
14
13
15
public MonitorLock ( object lockObj )
14
16
{
15
- Monitor . Enter ( lockObj ) ;
16
17
_lockObj = lockObj ;
17
18
}
18
19
20
+ public IDisposable Lock ( )
21
+ {
22
+ Monitor . Enter ( _lockObj ) ;
23
+ return this ;
24
+ }
25
+
19
26
public void Dispose ( )
20
27
{
21
28
Monitor . Exit ( _lockObj ) ;
22
29
}
23
30
}
24
31
32
+ public SyncCacheLock ( )
33
+ {
34
+ _monitorLock = new MonitorLock ( this ) ;
35
+ }
36
+
25
37
public void Dispose ( )
26
38
{
27
39
}
28
40
29
41
public IDisposable ReadLock ( )
30
42
{
31
- return new MonitorLock ( this ) ;
43
+ return _monitorLock . Lock ( ) ;
32
44
}
33
45
34
46
public IDisposable WriteLock ( )
35
47
{
36
- return new MonitorLock ( this ) ;
48
+ return _monitorLock . Lock ( ) ;
37
49
}
38
50
39
51
public Task < IDisposable > ReadLockAsync ( )
You can’t perform that action at this time.
0 commit comments