Reduce delegate allocation
This commit is contained in:
parent
facf3ad0da
commit
d104e8a08d
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
value = values[0];
|
value = values[0];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
value = String.Join(",", values);
|
value = string.Join(",", values.ToArray());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
var socket = new UvPipeHandle(Log);
|
var socket = new UvPipeHandle(Log);
|
||||||
socket.Init(Thread.Loop, false);
|
socket.Init(Thread.Loop, false);
|
||||||
socket.Bind(ServerAddress.UnixPipePath);
|
socket.Bind(ServerAddress.UnixPipePath);
|
||||||
socket.Listen(Constants.ListenBacklog, ConnectionCallback, this);
|
socket.Listen(Constants.ListenBacklog, (stream, status, error, state) => ConnectionCallback(stream, status, error, state), this);
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
var socket = new UvPipeHandle(Log);
|
var socket = new UvPipeHandle(Log);
|
||||||
socket.Init(Thread.Loop, false);
|
socket.Init(Thread.Loop, false);
|
||||||
socket.Bind(ServerAddress.UnixPipePath);
|
socket.Bind(ServerAddress.UnixPipePath);
|
||||||
socket.Listen(Constants.ListenBacklog, ConnectionCallback, this);
|
socket.Listen(Constants.ListenBacklog, (stream, status, error, state) => ConnectionCallback(stream, status, error, state), this);
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
socket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
socket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
||||||
socket.NoDelay(NoDelay);
|
socket.NoDelay(NoDelay);
|
||||||
socket.Bind(ServerAddress);
|
socket.Bind(ServerAddress);
|
||||||
socket.Listen(Constants.ListenBacklog, ConnectionCallback, this);
|
socket.Listen(Constants.ListenBacklog, (stream, status, error, state) => ConnectionCallback(stream, status, error, state), this);
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
socket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
socket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
||||||
socket.NoDelay(NoDelay);
|
socket.NoDelay(NoDelay);
|
||||||
socket.Bind(ServerAddress);
|
socket.Bind(ServerAddress);
|
||||||
socket.Listen(Constants.ListenBacklog, ConnectionCallback, this);
|
socket.Listen(Constants.ListenBacklog, (stream, status, error, state) => ConnectionCallback(stream, status, error, state), this);
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
{
|
{
|
||||||
public class UvAsyncHandle : UvHandle
|
public class UvAsyncHandle : UvHandle
|
||||||
{
|
{
|
||||||
private static Libuv.uv_async_cb _uv_async_cb = AsyncCb;
|
private static Libuv.uv_async_cb _uv_async_cb = (handle) => AsyncCb(handle);
|
||||||
private Action _callback;
|
private Action _callback;
|
||||||
|
|
||||||
public UvAsyncHandle(IKestrelTrace logger) : base(logger)
|
public UvAsyncHandle(IKestrelTrace logger) : base(logger)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UvConnectRequest : UvRequest
|
public class UvConnectRequest : UvRequest
|
||||||
{
|
{
|
||||||
private readonly static Libuv.uv_connect_cb _uv_connect_cb = UvConnectCb;
|
private readonly static Libuv.uv_connect_cb _uv_connect_cb = (req, status) => UvConnectCb(req, status);
|
||||||
|
|
||||||
private Action<UvConnectRequest, int, Exception, object> _callback;
|
private Action<UvConnectRequest, int, Exception, object> _callback;
|
||||||
private object _state;
|
private object _state;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
{
|
{
|
||||||
public abstract class UvHandle : UvMemory
|
public abstract class UvHandle : UvMemory
|
||||||
{
|
{
|
||||||
private static Libuv.uv_close_cb _destroyMemory = DestroyMemory;
|
private static Libuv.uv_close_cb _destroyMemory = (handle) => DestroyMemory(handle);
|
||||||
private Action<Action<IntPtr>, IntPtr> _queueCloseHandle;
|
private Action<Action<IntPtr>, IntPtr> _queueCloseHandle;
|
||||||
|
|
||||||
protected UvHandle(IKestrelTrace logger) : base (logger)
|
protected UvHandle(IKestrelTrace logger) : base (logger)
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,10 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
{
|
{
|
||||||
public abstract class UvStreamHandle : UvHandle
|
public abstract class UvStreamHandle : UvHandle
|
||||||
{
|
{
|
||||||
private readonly static Libuv.uv_connection_cb _uv_connection_cb = UvConnectionCb;
|
private readonly static Libuv.uv_connection_cb _uv_connection_cb = (handle, status) => UvConnectionCb(handle, status);
|
||||||
private readonly static Libuv.uv_alloc_cb _uv_alloc_cb = UvAllocCb;
|
// Ref and out lamda params must be explicitly typed
|
||||||
private readonly static Libuv.uv_read_cb _uv_read_cb = UvReadCb;
|
private readonly static Libuv.uv_alloc_cb _uv_alloc_cb = (IntPtr handle, int suggested_size, out Libuv.uv_buf_t buf) => UvAllocCb(handle, suggested_size, out buf);
|
||||||
|
private readonly static Libuv.uv_read_cb _uv_read_cb = (IntPtr handle, int status, ref Libuv.uv_buf_t buf) => UvReadCb(handle, status, ref buf);
|
||||||
|
|
||||||
public Action<UvStreamHandle, int, Exception, object> _listenCallback;
|
public Action<UvStreamHandle, int, Exception, object> _listenCallback;
|
||||||
public object _listenState;
|
public object _listenState;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue