Skip to content

Commit e33b9fa

Browse files
committed
Generic schedule methods to avoid casting
1 parent 3ce5e10 commit e33b9fa

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

projects/client/RabbitMQ.Client/src/client/impl/AsyncConsumerDispatcher.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,17 @@ public void HandleModelShutdown(IBasicConsumer consumer, ShutdownEventArgs reaso
6969
new ModelShutdown(consumer,reason).Execute(model).GetAwaiter().GetResult();
7070
}
7171

72-
private void ScheduleUnlessShuttingDown(Work work)
72+
private void ScheduleUnlessShuttingDown<TWork>(TWork work)
73+
where TWork : Work
7374
{
7475
if (!this.IsShutdown)
7576
{
7677
Schedule(work);
7778
}
7879
}
7980

80-
private void Schedule(Work work)
81+
private void Schedule<TWork>(TWork work)
82+
where TWork : Work
8183
{
8284
this.workService.Schedule(this.model, work);
8385
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ internal class AsyncConsumerWorkService
1010
{
1111
readonly ConcurrentDictionary<IModel, WorkPool> workPools = new ConcurrentDictionary<IModel, WorkPool>();
1212

13-
public void Schedule(ModelBase model, Work work)
13+
public void Schedule<TWork>(ModelBase model, TWork work)
14+
where TWork : Work
1415
{
1516
// two step approach is taken, as TryGetValue does not aquire locks
1617
// if this fails, GetOrAdd is called, which takes a lock

0 commit comments

Comments
 (0)