Remove unnecessary use of generics in listeners
This commit is contained in:
parent
803ec38073
commit
a9b8cfa582
|
|
@ -11,10 +11,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// <summary>
|
||||
/// Base class for listeners in Kestrel. Listens for incoming connections
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of socket used by this listener</typeparam>
|
||||
public abstract class Listener<T> : ListenerContext, IListener where T : UvStreamHandle
|
||||
public abstract class Listener : ListenerContext, IListener
|
||||
{
|
||||
protected T ListenSocket { get; private set; }
|
||||
protected UvStreamHandle ListenSocket { get; private set; }
|
||||
|
||||
protected static void ConnectionCallback(UvStreamHandle stream, int status, Exception error, object state)
|
||||
{
|
||||
|
|
@ -24,7 +23,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
}
|
||||
else
|
||||
{
|
||||
((Listener<T>)state).OnConnection((T)stream, status);
|
||||
((Listener)state).OnConnection(stream, status);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -62,16 +61,16 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// <summary>
|
||||
/// Creates the socket used to listen for incoming connections
|
||||
/// </summary>
|
||||
protected abstract T CreateListenSocket(string host, int port);
|
||||
protected abstract UvStreamHandle CreateListenSocket(string host, int port);
|
||||
|
||||
/// <summary>
|
||||
/// Handles an incoming connection
|
||||
/// </summary>
|
||||
/// <param name="listenSocket">Socket being used to listen on</param>
|
||||
/// <param name="status">Connection status</param>
|
||||
protected abstract void OnConnection(T listenSocket, int status);
|
||||
protected abstract void OnConnection(UvStreamHandle listenSocket, int status);
|
||||
|
||||
protected virtual void DispatchConnection(T socket)
|
||||
protected virtual void DispatchConnection(UvStreamHandle socket)
|
||||
{
|
||||
var connection = new Connection(this, socket);
|
||||
connection.Start();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// A primary listener waits for incoming connections on a specified socket. Incoming
|
||||
/// connections may be passed to a secondary listener to handle.
|
||||
/// </summary>
|
||||
abstract public class ListenerPrimary<T> : Listener<T>, IListenerPrimary where T : UvStreamHandle
|
||||
abstract public class ListenerPrimary : Listener, IListenerPrimary
|
||||
{
|
||||
UvPipeHandle ListenPipe { get; set; }
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
_dispatchPipes.Add(dispatchPipe);
|
||||
}
|
||||
|
||||
protected override void DispatchConnection(T socket)
|
||||
protected override void DispatchConnection(UvStreamHandle socket)
|
||||
{
|
||||
var index = _dispatchIndex++ % (_dispatchPipes.Count + 1);
|
||||
if (index == _dispatchPipes.Count)
|
||||
|
|
@ -84,7 +84,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
(write2, status, error, state) =>
|
||||
{
|
||||
write2.Dispose();
|
||||
((T)state).Dispose();
|
||||
((UvStreamHandle)state).Dispose();
|
||||
},
|
||||
socket);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// A secondary listener is delegated requests from a primary listener via a named pipe or
|
||||
/// UNIX domain socket.
|
||||
/// </summary>
|
||||
public abstract class ListenerSecondary<T> : ListenerContext, IListenerSecondary where T : UvStreamHandle
|
||||
public abstract class ListenerSecondary : ListenerContext, IListenerSecondary
|
||||
{
|
||||
UvPipeHandle DispatchPipe { get; set; }
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// <summary>
|
||||
/// Creates a socket which can be used to accept an incoming connection
|
||||
/// </summary>
|
||||
protected abstract T CreateAcceptSocket();
|
||||
protected abstract UvStreamHandle CreateAcceptSocket();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking;
|
|||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of <see cref="Listener{T}"/> that uses UNIX domain sockets as its transport.
|
||||
/// Implementation of <see cref="Listener"/> that uses UNIX domain sockets as its transport.
|
||||
/// </summary>
|
||||
public class PipeListener : Listener<UvPipeHandle>
|
||||
public class PipeListener : Listener
|
||||
{
|
||||
public PipeListener(IMemoryPool memory) : base(memory)
|
||||
{
|
||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// <summary>
|
||||
/// Creates the socket used to listen for incoming connections
|
||||
/// </summary>
|
||||
protected override UvPipeHandle CreateListenSocket(string host, int port)
|
||||
protected override UvStreamHandle CreateListenSocket(string host, int port)
|
||||
{
|
||||
var socket = new UvPipeHandle();
|
||||
socket.Init(Thread.Loop, false);
|
||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// </summary>
|
||||
/// <param name="listenSocket">Socket being used to listen on</param>
|
||||
/// <param name="status">Connection status</param>
|
||||
protected override void OnConnection(UvPipeHandle listenSocket, int status)
|
||||
protected override void OnConnection(UvStreamHandle listenSocket, int status)
|
||||
{
|
||||
var acceptSocket = new UvPipeHandle();
|
||||
acceptSocket.Init(Thread.Loop, false);
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking;
|
|||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// An implementation of <see cref="ListenerPrimary{T}"/> using UNIX sockets.
|
||||
/// An implementation of <see cref="ListenerPrimary"/> using UNIX sockets.
|
||||
/// </summary>
|
||||
public class PipeListenerPrimary : ListenerPrimary<UvPipeHandle>
|
||||
public class PipeListenerPrimary : ListenerPrimary
|
||||
{
|
||||
public PipeListenerPrimary(IMemoryPool memory) : base(memory)
|
||||
{
|
||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// <summary>
|
||||
/// Creates the socket used to listen for incoming connections
|
||||
/// </summary>
|
||||
protected override UvPipeHandle CreateListenSocket(string host, int port)
|
||||
protected override UvStreamHandle CreateListenSocket(string host, int port)
|
||||
{
|
||||
var socket = new UvPipeHandle();
|
||||
socket.Init(Thread.Loop, false);
|
||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// </summary>
|
||||
/// <param name="listenSocket">Socket being used to listen on</param>
|
||||
/// <param name="status">Connection status</param>
|
||||
protected override void OnConnection(UvPipeHandle listenSocket, int status)
|
||||
protected override void OnConnection(UvStreamHandle listenSocket, int status)
|
||||
{
|
||||
var acceptSocket = new UvPipeHandle();
|
||||
acceptSocket.Init(Thread.Loop, false);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking;
|
|||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// An implementation of <see cref="ListenerSecondary{T}"/> using UNIX sockets.
|
||||
/// An implementation of <see cref="ListenerSecondary"/> using UNIX sockets.
|
||||
/// </summary>
|
||||
public class PipeListenerSecondary : ListenerSecondary<UvPipeHandle>
|
||||
public class PipeListenerSecondary : ListenerSecondary
|
||||
{
|
||||
public PipeListenerSecondary(IMemoryPool memory) : base(memory)
|
||||
{
|
||||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// <summary>
|
||||
/// Creates a socket which can be used to accept an incoming connection
|
||||
/// </summary>
|
||||
protected override UvPipeHandle CreateAcceptSocket()
|
||||
protected override UvStreamHandle CreateAcceptSocket()
|
||||
{
|
||||
var acceptSocket = new UvPipeHandle();
|
||||
acceptSocket.Init(Thread.Loop, false);
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking;
|
|||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of <see cref="Listener{T}"/> that uses TCP sockets as its transport.
|
||||
/// Implementation of <see cref="Listener"/> that uses TCP sockets as its transport.
|
||||
/// </summary>
|
||||
public class TcpListener : Listener<UvTcpHandle>
|
||||
public class TcpListener : Listener
|
||||
{
|
||||
public TcpListener(IMemoryPool memory) : base(memory)
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// <summary>
|
||||
/// Creates the socket used to listen for incoming connections
|
||||
/// </summary>
|
||||
protected override UvTcpHandle CreateListenSocket(string host, int port)
|
||||
protected override UvStreamHandle CreateListenSocket(string host, int port)
|
||||
{
|
||||
var socket = new UvTcpHandle();
|
||||
socket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// </summary>
|
||||
/// <param name="listenSocket">Socket being used to listen on</param>
|
||||
/// <param name="status">Connection status</param>
|
||||
protected override void OnConnection(UvTcpHandle listenSocket, int status)
|
||||
protected override void OnConnection(UvStreamHandle listenSocket, int status)
|
||||
{
|
||||
var acceptSocket = new UvTcpHandle();
|
||||
acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking;
|
|||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// An implementation of <see cref="ListenerPrimary{T}"/> using TCP sockets.
|
||||
/// An implementation of <see cref="ListenerPrimary"/> using TCP sockets.
|
||||
/// </summary>
|
||||
public class TcpListenerPrimary : ListenerPrimary<UvTcpHandle>
|
||||
public class TcpListenerPrimary : ListenerPrimary
|
||||
{
|
||||
public TcpListenerPrimary(IMemoryPool memory) : base(memory)
|
||||
{
|
||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// <summary>
|
||||
/// Creates the socket used to listen for incoming connections
|
||||
/// </summary>
|
||||
protected override UvTcpHandle CreateListenSocket(string host, int port)
|
||||
protected override UvStreamHandle CreateListenSocket(string host, int port)
|
||||
{
|
||||
var socket = new UvTcpHandle();
|
||||
socket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// </summary>
|
||||
/// <param name="listenSocket">Socket being used to listen on</param>
|
||||
/// <param name="status">Connection status</param>
|
||||
protected override void OnConnection(UvTcpHandle listenSocket, int status)
|
||||
protected override void OnConnection(UvStreamHandle listenSocket, int status)
|
||||
{
|
||||
var acceptSocket = new UvTcpHandle();
|
||||
acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ using Microsoft.AspNet.Server.Kestrel.Networking;
|
|||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// An implementation of <see cref="ListenerSecondary{T}"/> using TCP sockets.
|
||||
/// An implementation of <see cref="ListenerSecondary"/> using TCP sockets.
|
||||
/// </summary>
|
||||
public class TcpListenerSecondary : ListenerSecondary<UvTcpHandle>
|
||||
public class TcpListenerSecondary : ListenerSecondary
|
||||
{
|
||||
public TcpListenerSecondary(IMemoryPool memory) : base(memory)
|
||||
{
|
||||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
|||
/// <summary>
|
||||
/// Creates a socket which can be used to accept an incoming connection
|
||||
/// </summary>
|
||||
protected override UvTcpHandle CreateAcceptSocket()
|
||||
protected override UvStreamHandle CreateAcceptSocket()
|
||||
{
|
||||
var acceptSocket = new UvTcpHandle();
|
||||
acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle);
|
||||
|
|
|
|||
Loading…
Reference in New Issue