Move non-nested classes and interfaces to their own files
This commit is contained in:
parent
fd038b7b91
commit
4b66edc4fe
|
|
@ -2,42 +2,11 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
public class ConnectionContext : ListenerContext
|
|
||||||
{
|
|
||||||
public ConnectionContext()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConnectionContext(ListenerContext context) : base(context)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConnectionContext(ConnectionContext context) : base(context)
|
|
||||||
{
|
|
||||||
SocketInput = context.SocketInput;
|
|
||||||
SocketOutput = context.SocketOutput;
|
|
||||||
ConnectionControl = context.ConnectionControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SocketInput SocketInput { get; set; }
|
|
||||||
public ISocketOutput SocketOutput { get; set; }
|
|
||||||
|
|
||||||
public IConnectionControl ConnectionControl { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IConnectionControl
|
|
||||||
{
|
|
||||||
void Pause();
|
|
||||||
void Resume();
|
|
||||||
void End(ProduceEndType endType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Connection : ConnectionContext, IConnectionControl
|
public class Connection : ConnectionContext, IConnectionControl
|
||||||
{
|
{
|
||||||
private static readonly Action<UvStreamHandle, int, Exception, object> _readCallback = ReadCallback;
|
private static readonly Action<UvStreamHandle, int, Exception, object> _readCallback = ReadCallback;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
|
{
|
||||||
|
public class ConnectionContext : ListenerContext
|
||||||
|
{
|
||||||
|
public ConnectionContext()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionContext(ListenerContext context) : base(context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionContext(ConnectionContext context) : base(context)
|
||||||
|
{
|
||||||
|
SocketInput = context.SocketInput;
|
||||||
|
SocketOutput = context.SocketOutput;
|
||||||
|
ConnectionControl = context.ConnectionControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SocketInput SocketInput { get; set; }
|
||||||
|
public ISocketOutput SocketOutput { get; set; }
|
||||||
|
|
||||||
|
public IConnectionControl ConnectionControl { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,35 +13,6 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
|
|
||||||
public enum ProduceEndType
|
|
||||||
{
|
|
||||||
SocketShutdownSend,
|
|
||||||
SocketDisconnect,
|
|
||||||
ConnectionKeepAlive,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FrameContext : ConnectionContext
|
|
||||||
{
|
|
||||||
public FrameContext()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public FrameContext(ConnectionContext context) : base(context)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IFrameControl FrameControl { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IFrameControl
|
|
||||||
{
|
|
||||||
void ProduceContinue();
|
|
||||||
void Write(ArraySegment<byte> data, Action<Exception, object> callback, object state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Frame : FrameContext, IFrameControl
|
public class Frame : FrameContext, IFrameControl
|
||||||
{
|
{
|
||||||
enum Mode
|
enum Mode
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
|
{
|
||||||
|
public class FrameContext : ConnectionContext
|
||||||
|
{
|
||||||
|
public FrameContext()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public FrameContext(ConnectionContext context) : base(context)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFrameControl FrameControl { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
|
{
|
||||||
|
public interface IConnectionControl
|
||||||
|
{
|
||||||
|
void Pause();
|
||||||
|
void Resume();
|
||||||
|
void End(ProduceEndType endType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
|
{
|
||||||
|
public interface IFrameControl
|
||||||
|
{
|
||||||
|
void ProduceContinue();
|
||||||
|
void Write(ArraySegment<byte> data, Action<Exception, object> callback, object state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
|
{
|
||||||
|
public interface IMemoryPool
|
||||||
|
{
|
||||||
|
byte[] Empty { get; }
|
||||||
|
|
||||||
|
byte[] AllocByte(int minimumSize);
|
||||||
|
void FreeByte(byte[] memory);
|
||||||
|
|
||||||
|
char[] AllocChar(int minimumSize);
|
||||||
|
void FreeChar(char[] memory);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Acquires a sub-segment of a larger memory allocation. Used for async sends of write-behind
|
||||||
|
/// buffers to reduce number of array segments pinned
|
||||||
|
/// </summary>
|
||||||
|
/// <param name = "minimumSize">The smallest length of the ArraySegment.Count that may be returned</param>
|
||||||
|
/// <returns>An array segment which is a sub-block of a larger allocation</returns>
|
||||||
|
ArraySegment<byte> AllocSegment(int minimumSize);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Frees a sub-segment of a larger memory allocation produced by AllocSegment. The original ArraySegment
|
||||||
|
/// must be frees exactly once and must have the same offset and count that was returned by the Alloc.
|
||||||
|
/// If a segment is not freed it won't be re-used and has the same effect as a memory leak, so callers must be
|
||||||
|
/// implemented exactly correctly.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name = "segment">The sub-block that was originally returned by a call to AllocSegment.</param>
|
||||||
|
void FreeSegment(ArraySegment<byte> segment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Operations performed for buffered socket output
|
||||||
|
/// </summary>
|
||||||
|
public interface ISocketOutput
|
||||||
|
{
|
||||||
|
void Write(ArraySegment<byte> buffer, Action<Exception, object> callback, object state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,24 +9,6 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
public class ListenerContext
|
|
||||||
{
|
|
||||||
public ListenerContext() { }
|
|
||||||
|
|
||||||
public ListenerContext(ListenerContext context)
|
|
||||||
{
|
|
||||||
Thread = context.Thread;
|
|
||||||
Application = context.Application;
|
|
||||||
Memory = context.Memory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KestrelThread Thread { get; set; }
|
|
||||||
|
|
||||||
public Func<Frame, Task> Application { get; set; }
|
|
||||||
|
|
||||||
public IMemoryPool Memory { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Summary description for Accept
|
/// Summary description for Accept
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
|
{
|
||||||
|
public class ListenerContext
|
||||||
|
{
|
||||||
|
public ListenerContext() { }
|
||||||
|
|
||||||
|
public ListenerContext(ListenerContext context)
|
||||||
|
{
|
||||||
|
Thread = context.Thread;
|
||||||
|
Application = context.Application;
|
||||||
|
Memory = context.Memory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public KestrelThread Thread { get; set; }
|
||||||
|
|
||||||
|
public Func<Frame, Task> Application { get; set; }
|
||||||
|
|
||||||
|
public IMemoryPool Memory { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,34 +6,6 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
public interface IMemoryPool
|
|
||||||
{
|
|
||||||
byte[] Empty { get; }
|
|
||||||
|
|
||||||
byte[] AllocByte(int minimumSize);
|
|
||||||
void FreeByte(byte[] memory);
|
|
||||||
|
|
||||||
char[] AllocChar(int minimumSize);
|
|
||||||
void FreeChar(char[] memory);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Acquires a sub-segment of a larger memory allocation. Used for async sends of write-behind
|
|
||||||
/// buffers to reduce number of array segments pinned
|
|
||||||
/// </summary>
|
|
||||||
/// <param name = "minimumSize">The smallest length of the ArraySegment.Count that may be returned</param>
|
|
||||||
/// <returns>An array segment which is a sub-block of a larger allocation</returns>
|
|
||||||
ArraySegment<byte> AllocSegment(int minimumSize);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Frees a sub-segment of a larger memory allocation produced by AllocSegment. The original ArraySegment
|
|
||||||
/// must be frees exactly once and must have the same offset and count that was returned by the Alloc.
|
|
||||||
/// If a segment is not freed it won't be re-used and has the same effect as a memory leak, so callers must be
|
|
||||||
/// implemented exactly correctly.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name = "segment">The sub-block that was originally returned by a call to AllocSegment.</param>
|
|
||||||
void FreeSegment(ArraySegment<byte> segment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MemoryPool : IMemoryPool
|
public class MemoryPool : IMemoryPool
|
||||||
{
|
{
|
||||||
static readonly byte[] EmptyArray = new byte[0];
|
static readonly byte[] EmptyArray = new byte[0];
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
|
{
|
||||||
|
public enum ProduceEndType
|
||||||
|
{
|
||||||
|
SocketShutdownSend,
|
||||||
|
SocketDisconnect,
|
||||||
|
ConnectionKeepAlive,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,19 +3,10 @@
|
||||||
|
|
||||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Http
|
namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Operations performed for buffered socket output
|
|
||||||
/// </summary>
|
|
||||||
public interface ISocketOutput
|
|
||||||
{
|
|
||||||
void Write(ArraySegment<byte> buffer, Action<Exception, object> callback, object state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SocketOutput : ISocketOutput
|
public class SocketOutput : ISocketOutput
|
||||||
{
|
{
|
||||||
private readonly KestrelThread _thread;
|
private readonly KestrelThread _thread;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Networking
|
namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Networking
|
namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
_uv.async_send(this);
|
_uv.async_send(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe static void AsyncCb(IntPtr handle)
|
unsafe private static void AsyncCb(IntPtr handle)
|
||||||
{
|
{
|
||||||
FromIntPtr<UvAsyncHandle>(handle)._callback.Invoke();
|
FromIntPtr<UvAsyncHandle>(handle)._callback.Invoke();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
|
{
|
||||||
|
public abstract class UvReq : UvMemory
|
||||||
|
{
|
||||||
|
protected override bool ReleaseHandle()
|
||||||
|
{
|
||||||
|
DestroyMemory(handle);
|
||||||
|
handle = IntPtr.Zero;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
@ -117,14 +114,4 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class UvReq : UvMemory
|
|
||||||
{
|
|
||||||
protected override bool ReleaseHandle()
|
|
||||||
{
|
|
||||||
DestroyMemory(handle);
|
|
||||||
handle = IntPtr.Zero;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue