File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -31,19 +31,18 @@ using CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSec
3131// acquire writer lock
3232using var d2 = await asyncLock .WriterLockAsync (" 123" , cts .Token );
3333
34- // use writer lock scope
35-
36- using var r1 = await asyncLock .ReaderLockAsync ();
37-
38- // use reader lock
39-
40- if (.. )
34+ // use writer lock scope to break long running reader lock
35+ using (var r1 = await lockEntity .ReaderLockAsync ())
4136{
42- r1 .UseWriterLockAsync (async () => { /* use writer lock here*/ });
43- }
37+ // use reader lock
4438
45- // continue with reader lock
39+ if (.. )
40+ {
41+ r1 .UseWriterLockAsync (async () => { /* use writer lock here*/ });
42+ }
4643
44+ // continue with reader lock
45+ }
4746```
4847
4948### Benchmarks
You can’t perform that action at this time.
0 commit comments