Skip to content

Commit 26696ef

Browse files
committed
Don't use compiler shenanigans for AsyncRpcContinuation
1 parent 48dac7b commit 26696ef

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

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

+2-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
using System;
3333
using System.Diagnostics;
34-
using System.Runtime.CompilerServices;
3534
using System.Threading;
3635
using System.Threading.Tasks;
3736
using RabbitMQ.Client.client.framing;
@@ -44,7 +43,6 @@ namespace RabbitMQ.Client.Impl
4443
internal abstract class AsyncRpcContinuation<T> : IRpcContinuation, IDisposable
4544
{
4645
private readonly CancellationTokenSource _cancellationTokenSource;
47-
private readonly ConfiguredTaskAwaitable<T> _taskAwaitable;
4846

4947
protected readonly TaskCompletionSource<T> _tcs = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
5048

@@ -68,13 +66,11 @@ public AsyncRpcContinuation(TimeSpan continuationTimeout)
6866
// in the same manner as BlockingCell?
6967
}
7068
}, useSynchronizationContext: false);
71-
72-
_taskAwaitable = _tcs.Task.ConfigureAwait(false);
7369
}
7470

75-
public ConfiguredTaskAwaitable<T>.ConfiguredTaskAwaiter GetAwaiter()
71+
public Task<T> WaitAsync()
7672
{
77-
return _taskAwaitable.GetAwaiter();
73+
return _tcs.Task;
7874
}
7975

8076
public abstract void HandleCommand(in IncomingCommand cmd);

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

+42-21
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ await ModelSendAsync(method)
253253
.ConfigureAwait(false);
254254
}
255255

256-
bool result = await k;
256+
bool result = await k.WaitAsync()
257+
.ConfigureAwait(false);
257258
Debug.Assert(result);
258259

259260
await ConsumerDispatcher.WaitForShutdownAsync()
@@ -318,7 +319,8 @@ await ModelSendAsync(method)
318319
// negotiation finishes
319320
}
320321

321-
return await k;
322+
return await k.WaitAsync()
323+
.ConfigureAwait(false);
322324
}
323325
finally
324326
{
@@ -349,7 +351,8 @@ await ModelSendAsync(method)
349351
// negotiation finishes
350352
}
351353

352-
return await k;
354+
return await k.WaitAsync()
355+
.ConfigureAwait(false);
353356
}
354357
finally
355358
{
@@ -384,7 +387,8 @@ await _rpcSemaphore.WaitAsync()
384387
await ModelSendAsync(method)
385388
.ConfigureAwait(false);
386389

387-
bool result = await k;
390+
bool result = await k.WaitAsync()
391+
.ConfigureAwait(false);
388392
Debug.Assert(result);
389393
return this;
390394
}
@@ -1089,7 +1093,8 @@ await _rpcSemaphore.WaitAsync()
10891093
await ModelSendAsync(method)
10901094
.ConfigureAwait(false);
10911095

1092-
bool result = await k;
1096+
bool result = await k.WaitAsync()
1097+
.ConfigureAwait(false);
10931098
Debug.Assert(result);
10941099
return;
10951100
}
@@ -1163,7 +1168,8 @@ await _rpcSemaphore.WaitAsync()
11631168
await ModelSendAsync(method)
11641169
.ConfigureAwait(false);
11651170

1166-
return await k;
1171+
return await k.WaitAsync()
1172+
.ConfigureAwait(false);
11671173
}
11681174
finally
11691175
{
@@ -1203,7 +1209,8 @@ await _rpcSemaphore.WaitAsync()
12031209
await ModelSendAsync(method)
12041210
.ConfigureAwait(false);
12051211

1206-
return await k;
1212+
return await k.WaitAsync()
1213+
.ConfigureAwait(false);
12071214
}
12081215
finally
12091216
{
@@ -1305,7 +1312,8 @@ await _rpcSemaphore.WaitAsync()
13051312
await ModelSendAsync(method)
13061313
.ConfigureAwait(false);
13071314

1308-
bool result = await k;
1315+
bool result = await k.WaitAsync()
1316+
.ConfigureAwait(false);
13091317
Debug.Assert(result);
13101318
return;
13111319
}
@@ -1349,7 +1357,8 @@ await _rpcSemaphore.WaitAsync()
13491357
await ModelSendAsync(method)
13501358
.ConfigureAwait(false);
13511359

1352-
bool result = await k;
1360+
bool result = await k.WaitAsync()
1361+
.ConfigureAwait(false);
13531362
Debug.Assert(result);
13541363

13551364
return;
@@ -1378,7 +1387,8 @@ await _rpcSemaphore.WaitAsync()
13781387
await ModelSendAsync(method)
13791388
.ConfigureAwait(false);
13801389

1381-
bool result = await k;
1390+
bool result = await k.WaitAsync()
1391+
.ConfigureAwait(false);
13821392
Debug.Assert(result);
13831393
return;
13841394
}
@@ -1411,7 +1421,8 @@ await _rpcSemaphore.WaitAsync()
14111421
await ModelSendAsync(method)
14121422
.ConfigureAwait(false);
14131423

1414-
bool result = await k;
1424+
bool result = await k.WaitAsync()
1425+
.ConfigureAwait(false);
14151426
Debug.Assert(result);
14161427
return;
14171428
}
@@ -1449,7 +1460,8 @@ await _rpcSemaphore.WaitAsync()
14491460
await ModelSendAsync(method)
14501461
.ConfigureAwait(false);
14511462

1452-
bool result = await k;
1463+
bool result = await k.WaitAsync()
1464+
.ConfigureAwait(false);
14531465
Debug.Assert(result);
14541466
return;
14551467
}
@@ -1482,7 +1494,8 @@ await _rpcSemaphore.WaitAsync()
14821494
await ModelSendAsync(method)
14831495
.ConfigureAwait(false);
14841496

1485-
bool result = await k;
1497+
bool result = await k.WaitAsync()
1498+
.ConfigureAwait(false);
14861499
Debug.Assert(result);
14871500
return;
14881501
}
@@ -1525,7 +1538,8 @@ await _rpcSemaphore.WaitAsync()
15251538
await ModelSendAsync(method)
15261539
.ConfigureAwait(false);
15271540

1528-
QueueDeclareOk result = await k;
1541+
QueueDeclareOk result = await k.WaitAsync()
1542+
.ConfigureAwait(false);
15291543
if (false == passive)
15301544
{
15311545
CurrentQueue = result.QueueName;
@@ -1551,7 +1565,8 @@ await _rpcSemaphore.WaitAsync()
15511565
await ModelSendAsync(method)
15521566
.ConfigureAwait(false);
15531567

1554-
bool result = await k;
1568+
bool result = await k.WaitAsync()
1569+
.ConfigureAwait(false);
15551570
Debug.Assert(result);
15561571
return;
15571572
}
@@ -1601,7 +1616,8 @@ await _rpcSemaphore.WaitAsync()
16011616
await ModelSendAsync(method)
16021617
.ConfigureAwait(false);
16031618

1604-
return await k;
1619+
return await k.WaitAsync()
1620+
.ConfigureAwait(false);
16051621
}
16061622
finally
16071623
{
@@ -1632,7 +1648,8 @@ await _rpcSemaphore.WaitAsync()
16321648
await ModelSendAsync(method)
16331649
.ConfigureAwait(false);
16341650

1635-
return await k;
1651+
return await k.WaitAsync()
1652+
.ConfigureAwait(false);
16361653
}
16371654
finally
16381655
{
@@ -1655,7 +1672,8 @@ await _rpcSemaphore.WaitAsync()
16551672
await ModelSendAsync(method)
16561673
.ConfigureAwait(false);
16571674

1658-
bool result = await k;
1675+
bool result = await k.WaitAsync()
1676+
.ConfigureAwait(false);
16591677
Debug.Assert(result);
16601678
return;
16611679
}
@@ -1680,7 +1698,8 @@ await _rpcSemaphore.WaitAsync()
16801698
await ModelSendAsync(method)
16811699
.ConfigureAwait(false);
16821700

1683-
bool result = await k;
1701+
bool result = await k.WaitAsync()
1702+
.ConfigureAwait(false);
16841703
Debug.Assert(result);
16851704
return;
16861705
}
@@ -1705,7 +1724,8 @@ await _rpcSemaphore.WaitAsync()
17051724
await ModelSendAsync(method)
17061725
.ConfigureAwait(false);
17071726

1708-
bool result = await k;
1727+
bool result = await k.WaitAsync()
1728+
.ConfigureAwait(false);
17091729
Debug.Assert(result);
17101730
return;
17111731
}
@@ -1730,7 +1750,8 @@ await _rpcSemaphore.WaitAsync()
17301750
await ModelSendAsync(method)
17311751
.ConfigureAwait(false);
17321752

1733-
bool result = await k;
1753+
bool result = await k.WaitAsync()
1754+
.ConfigureAwait(false);
17341755
Debug.Assert(result);
17351756
return;
17361757
}

0 commit comments

Comments
 (0)