Use ReferenceEquals not MulticastDelegate.equals (#2330)
It never inlines because its such a chunky method
This commit is contained in:
parent
07026cf6db
commit
1f8591184e
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
||||||
};
|
};
|
||||||
|
|
||||||
public LibuvAwaitable<TRequest> GetAwaiter() => this;
|
public LibuvAwaitable<TRequest> GetAwaiter() => this;
|
||||||
public bool IsCompleted => _callback == _callbackCompleted;
|
public bool IsCompleted => ReferenceEquals(_callback, _callbackCompleted);
|
||||||
|
|
||||||
public UvWriteResult GetResult()
|
public UvWriteResult GetResult()
|
||||||
{
|
{
|
||||||
|
|
@ -54,8 +54,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
||||||
// There should never be a race between IsCompleted and OnCompleted since both operations
|
// There should never be a race between IsCompleted and OnCompleted since both operations
|
||||||
// should always be on the libuv thread
|
// should always be on the libuv thread
|
||||||
|
|
||||||
if (_callback == _callbackCompleted ||
|
if (ReferenceEquals(_callback, _callbackCompleted) ||
|
||||||
Interlocked.CompareExchange(ref _callback, continuation, null) == _callbackCompleted)
|
ReferenceEquals(Interlocked.CompareExchange(ref _callback, continuation, null), _callbackCompleted))
|
||||||
{
|
{
|
||||||
Debug.Fail($"{typeof(LibuvAwaitable<TRequest>)}.{nameof(OnCompleted)} raced with {nameof(IsCompleted)}, running callback inline.");
|
Debug.Fail($"{typeof(LibuvAwaitable<TRequest>)}.{nameof(OnCompleted)} raced with {nameof(IsCompleted)}, running callback inline.");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
|
||||||
private SocketError _error;
|
private SocketError _error;
|
||||||
|
|
||||||
public SocketAwaitable GetAwaiter() => this;
|
public SocketAwaitable GetAwaiter() => this;
|
||||||
public bool IsCompleted => _callback == _callbackCompleted;
|
public bool IsCompleted => ReferenceEquals(_callback, _callbackCompleted);
|
||||||
|
|
||||||
public int GetResult()
|
public int GetResult()
|
||||||
{
|
{
|
||||||
Debug.Assert(_callback == _callbackCompleted);
|
Debug.Assert(ReferenceEquals(_callback, _callbackCompleted));
|
||||||
|
|
||||||
_callback = null;
|
_callback = null;
|
||||||
|
|
||||||
|
|
@ -36,8 +36,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
|
||||||
|
|
||||||
public void OnCompleted(Action continuation)
|
public void OnCompleted(Action continuation)
|
||||||
{
|
{
|
||||||
if (_callback == _callbackCompleted ||
|
if (ReferenceEquals(_callback, _callbackCompleted) ||
|
||||||
Interlocked.CompareExchange(ref _callback, continuation, null) == _callbackCompleted)
|
ReferenceEquals(Interlocked.CompareExchange(ref _callback, continuation, null), _callbackCompleted))
|
||||||
{
|
{
|
||||||
continuation();
|
continuation();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue