Skip to content

Commit e1ffbb5

Browse files
committed
Manually revert commit 26696ef
1 parent 5b2cd95 commit e1ffbb5

File tree

2 files changed

+27
-44
lines changed

2 files changed

+27
-44
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
using System;
3333
using System.Diagnostics;
34+
using System.Runtime.CompilerServices;
3435
using System.Threading;
3536
using System.Threading.Tasks;
3637
using RabbitMQ.Client.client.framing;
@@ -43,6 +44,7 @@ namespace RabbitMQ.Client.Impl
4344
internal abstract class AsyncRpcContinuation<T> : IRpcContinuation, IDisposable
4445
{
4546
private readonly CancellationTokenSource _cancellationTokenSource;
47+
private readonly ConfiguredTaskAwaitable<T> _tcsConfiguredTaskAwaitable;
4648

4749
protected readonly TaskCompletionSource<T> _tcs = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
4850

@@ -66,11 +68,13 @@ public AsyncRpcContinuation(TimeSpan continuationTimeout)
6668
// in the same manner as BlockingCell?
6769
}
6870
}, useSynchronizationContext: false);
71+
72+
_tcsConfiguredTaskAwaitable = _tcs.Task.ConfigureAwait(false);
6973
}
7074

71-
public Task<T> WaitAsync()
75+
public ConfiguredTaskAwaitable<T>.ConfiguredTaskAwaiter GetAwaiter()
7276
{
73-
return _tcs.Task;
77+
return _tcsConfiguredTaskAwaitable.GetAwaiter();
7478
}
7579

7680
public abstract void HandleCommand(in IncomingCommand cmd);

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

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

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

260259
await ConsumerDispatcher.WaitForShutdownAsync()
@@ -319,8 +318,7 @@ await ModelSendAsync(method)
319318
// negotiation finishes
320319
}
321320

322-
return await k.WaitAsync()
323-
.ConfigureAwait(false);
321+
return await k;
324322
}
325323
finally
326324
{
@@ -351,8 +349,7 @@ await ModelSendAsync(method)
351349
// negotiation finishes
352350
}
353351

354-
return await k.WaitAsync()
355-
.ConfigureAwait(false);
352+
return await k;
356353
}
357354
finally
358355
{
@@ -387,8 +384,7 @@ await _rpcSemaphore.WaitAsync()
387384
await ModelSendAsync(method)
388385
.ConfigureAwait(false);
389386

390-
bool result = await k.WaitAsync()
391-
.ConfigureAwait(false);
387+
bool result = await k;
392388
Debug.Assert(result);
393389
return this;
394390
}
@@ -1093,8 +1089,7 @@ await _rpcSemaphore.WaitAsync()
10931089
await ModelSendAsync(method)
10941090
.ConfigureAwait(false);
10951091

1096-
bool result = await k.WaitAsync()
1097-
.ConfigureAwait(false);
1092+
bool result = await k;
10981093
Debug.Assert(result);
10991094
return;
11001095
}
@@ -1168,8 +1163,7 @@ await _rpcSemaphore.WaitAsync()
11681163
await ModelSendAsync(method)
11691164
.ConfigureAwait(false);
11701165

1171-
return await k.WaitAsync()
1172-
.ConfigureAwait(false);
1166+
return await k;
11731167
}
11741168
finally
11751169
{
@@ -1209,8 +1203,7 @@ await _rpcSemaphore.WaitAsync()
12091203
await ModelSendAsync(method)
12101204
.ConfigureAwait(false);
12111205

1212-
return await k.WaitAsync()
1213-
.ConfigureAwait(false);
1206+
return await k;
12141207
}
12151208
finally
12161209
{
@@ -1312,8 +1305,7 @@ await _rpcSemaphore.WaitAsync()
13121305
await ModelSendAsync(method)
13131306
.ConfigureAwait(false);
13141307

1315-
bool result = await k.WaitAsync()
1316-
.ConfigureAwait(false);
1308+
bool result = await k;
13171309
Debug.Assert(result);
13181310
return;
13191311
}
@@ -1357,8 +1349,7 @@ await _rpcSemaphore.WaitAsync()
13571349
await ModelSendAsync(method)
13581350
.ConfigureAwait(false);
13591351

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

13641355
return;
@@ -1387,8 +1378,7 @@ await _rpcSemaphore.WaitAsync()
13871378
await ModelSendAsync(method)
13881379
.ConfigureAwait(false);
13891380

1390-
bool result = await k.WaitAsync()
1391-
.ConfigureAwait(false);
1381+
bool result = await k;
13921382
Debug.Assert(result);
13931383
return;
13941384
}
@@ -1421,8 +1411,7 @@ await _rpcSemaphore.WaitAsync()
14211411
await ModelSendAsync(method)
14221412
.ConfigureAwait(false);
14231413

1424-
bool result = await k.WaitAsync()
1425-
.ConfigureAwait(false);
1414+
bool result = await k;
14261415
Debug.Assert(result);
14271416
return;
14281417
}
@@ -1460,8 +1449,7 @@ await _rpcSemaphore.WaitAsync()
14601449
await ModelSendAsync(method)
14611450
.ConfigureAwait(false);
14621451

1463-
bool result = await k.WaitAsync()
1464-
.ConfigureAwait(false);
1452+
bool result = await k;
14651453
Debug.Assert(result);
14661454
return;
14671455
}
@@ -1494,8 +1482,7 @@ await _rpcSemaphore.WaitAsync()
14941482
await ModelSendAsync(method)
14951483
.ConfigureAwait(false);
14961484

1497-
bool result = await k.WaitAsync()
1498-
.ConfigureAwait(false);
1485+
bool result = await k;
14991486
Debug.Assert(result);
15001487
return;
15011488
}
@@ -1538,8 +1525,7 @@ await _rpcSemaphore.WaitAsync()
15381525
await ModelSendAsync(method)
15391526
.ConfigureAwait(false);
15401527

1541-
QueueDeclareOk result = await k.WaitAsync()
1542-
.ConfigureAwait(false);
1528+
QueueDeclareOk result = await k;
15431529
if (false == passive)
15441530
{
15451531
CurrentQueue = result.QueueName;
@@ -1565,8 +1551,7 @@ await _rpcSemaphore.WaitAsync()
15651551
await ModelSendAsync(method)
15661552
.ConfigureAwait(false);
15671553

1568-
bool result = await k.WaitAsync()
1569-
.ConfigureAwait(false);
1554+
bool result = await k;
15701555
Debug.Assert(result);
15711556
return;
15721557
}
@@ -1616,8 +1601,7 @@ await _rpcSemaphore.WaitAsync()
16161601
await ModelSendAsync(method)
16171602
.ConfigureAwait(false);
16181603

1619-
return await k.WaitAsync()
1620-
.ConfigureAwait(false);
1604+
return await k;
16211605
}
16221606
finally
16231607
{
@@ -1648,8 +1632,7 @@ await _rpcSemaphore.WaitAsync()
16481632
await ModelSendAsync(method)
16491633
.ConfigureAwait(false);
16501634

1651-
return await k.WaitAsync()
1652-
.ConfigureAwait(false);
1635+
return await k;
16531636
}
16541637
finally
16551638
{
@@ -1672,8 +1655,7 @@ await _rpcSemaphore.WaitAsync()
16721655
await ModelSendAsync(method)
16731656
.ConfigureAwait(false);
16741657

1675-
bool result = await k.WaitAsync()
1676-
.ConfigureAwait(false);
1658+
bool result = await k;
16771659
Debug.Assert(result);
16781660
return;
16791661
}
@@ -1698,8 +1680,7 @@ await _rpcSemaphore.WaitAsync()
16981680
await ModelSendAsync(method)
16991681
.ConfigureAwait(false);
17001682

1701-
bool result = await k.WaitAsync()
1702-
.ConfigureAwait(false);
1683+
bool result = await k;
17031684
Debug.Assert(result);
17041685
return;
17051686
}
@@ -1724,8 +1705,7 @@ await _rpcSemaphore.WaitAsync()
17241705
await ModelSendAsync(method)
17251706
.ConfigureAwait(false);
17261707

1727-
bool result = await k.WaitAsync()
1728-
.ConfigureAwait(false);
1708+
bool result = await k;
17291709
Debug.Assert(result);
17301710
return;
17311711
}
@@ -1750,8 +1730,7 @@ await _rpcSemaphore.WaitAsync()
17501730
await ModelSendAsync(method)
17511731
.ConfigureAwait(false);
17521732

1753-
bool result = await k.WaitAsync()
1754-
.ConfigureAwait(false);
1733+
bool result = await k;
17551734
Debug.Assert(result);
17561735
return;
17571736
}

0 commit comments

Comments
 (0)