Skip to content

Commit 1b628e3

Browse files
committed
getting rid of a Func allocation
1 parent 335e9f1 commit 1b628e3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

projects/RabbitMQ.Client/client/impl/AsyncConsumerWorkService.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ namespace RabbitMQ.Client.Impl
88
{
99
internal sealed class AsyncConsumerWorkService : ConsumerWorkService
1010
{
11-
private readonly ConcurrentDictionary<IModel, WorkPool> _workPools = new ConcurrentDictionary<IModel, WorkPool>();
11+
private readonly ConcurrentDictionary<IModel, WorkPool> _workPools;
12+
private readonly Func<IModel, WorkPool> _startNewWorkPoolAction;
13+
14+
public AsyncConsumerWorkService()
15+
{
16+
_workPools = new ConcurrentDictionary<IModel, WorkPool>();
17+
_startNewWorkPoolAction = model => StartNewWorkPool(model);
18+
}
1219

1320
public void Schedule<TWork>(ModelBase model, TWork work) where TWork : Work
1421
{
15-
_workPools.GetOrAdd(model, StartNewWorkPool).Enqueue(work);
22+
_workPools.GetOrAdd(model, _startNewWorkPoolAction).Enqueue(work);
1623
}
1724

1825
private WorkPool StartNewWorkPool(IModel model)

0 commit comments

Comments
 (0)