Skip to content

Commit d387eff

Browse files
committed
Removed skipWaitingWriters
1 parent 0c20ee1 commit d387eff

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/AsyncLock.Tests/AsyncLockTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public async Task CancelWriterLock()
137137
{
138138
AsyncLock lockEntity = new AsyncLock();
139139

140-
CancellationTokenSource source = new CancellationTokenSource(TimeSpan.FromSeconds(1));
140+
using CancellationTokenSource source = new CancellationTokenSource(TimeSpan.FromSeconds(1));
141141

142142
using var w1 = await lockEntity.WriterLockAsync();
143143

src/AsyncLock/AsyncLock.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public AsyncLock()
1515
}
1616

1717
internal AsyncLock(object syncObject)
18-
: this()
1918
{
2019
_syncObj = syncObject;
2120
}
@@ -120,15 +119,15 @@ public Task<AsyncLockReleaser> WriterLockAsync(CancellationToken cancellation =
120119
}
121120
}
122121

123-
internal void Release(AsyncLockType type, bool skipWaitingWriters = false, bool sendReleasedEvent = true)
122+
internal void Release(AsyncLockType type, bool sendReleasedEvent = true)
124123
{
125124
lock (_syncObj)
126125
{
127126
try
128127
{
129128
if (type == AsyncLockType.Write)
130129
{
131-
WriterRelease(skipWaitingWriters);
130+
WriterRelease();
132131
}
133132
else
134133
{
@@ -156,15 +155,10 @@ private void ReaderRelease()
156155
}
157156
}
158157

159-
private void WriterRelease(bool skipWaitingWriters)
158+
private void WriterRelease()
160159
{
161-
_isWriterRunning = false;
162-
163160
//start next writer lock?
164-
if (skipWaitingWriters == false)
165-
{
166-
StartNextWaitingWriter();
167-
}
161+
StartNextWaitingWriter();
168162

169163
//no running writer lock?
170164
if (_isWriterRunning == false)

src/AsyncLock/AsyncLockReleaser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal AsyncLockReleaser(AsyncLock asyncLock, AsyncLockType type)
1818
_type = type;
1919
}
2020

21-
internal AsyncLockType? Type => _type;
21+
internal AsyncLockType Type => _type;
2222

2323
internal AsyncLock AsyncLock => _asyncLock;
2424

0 commit comments

Comments
 (0)