Skip to content

Commit 26b945d

Browse files
author
Oren (electricessence)
committed
Cleanup and version updates.
1 parent 0f72da6 commit 26b945d

2 files changed

Lines changed: 7 additions & 17 deletions

File tree

Filters/AutoComplete.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,11 @@ internal class AutoCompleteFilter<T> : TargetBlockFilter<T>
88
{
99
public AutoCompleteFilter(int limit, ITargetBlock<T> target) : base(target)
1010
{
11-
_limit = limit;
12-
}
13-
14-
private readonly int _limit;
15-
public int Limit
16-
{
17-
get { return _limit; }
18-
}
19-
20-
private int _allowed = 0;
21-
public int AllowedCount
22-
{
23-
get { return _allowed; }
11+
Limit = limit;
2412
}
2513

14+
public int Limit { get; }
15+
public int AllowedCount { get; private set; }
2616

2717

2818
// The key here is to reject the message ahead of time.
@@ -32,12 +22,12 @@ public override DataflowMessageStatus OfferMessage(DataflowMessageHeader message
3222
var completed = false;
3323
// There are multiple operations happening here that require synchronization to get right.
3424
ThreadSafety.LockConditional(_target,
35-
() => _allowed < _limit,
25+
() => AllowedCount < Limit,
3626
() =>
3727
{
38-
_allowed++;
28+
AllowedCount++;
3929
result = _target.OfferMessage(messageHeader, messageValue, source, consumeToAccept);
40-
completed = _allowed == _limit;
30+
completed = AllowedCount == Limit;
4131
}
4232
);
4333

Open.Threading.Dataflow.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Part of the "Open" set of libraries.</Description>
3737
</ItemGroup>
3838

3939
<ItemGroup>
40-
<PackageReference Include="Open.Threading" Version="1.4.1" />
40+
<PackageReference Include="Open.Threading" Version="1.4.2" />
4141
<PackageReference Include="Open.Threading.Tasks" Version="1.1.3" />
4242
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
4343
</ItemGroup>

0 commit comments

Comments
 (0)