// 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.Http
{
public interface IMemoryPool
{
byte[] Empty { get; }
byte[] AllocByte(int minimumSize);
void FreeByte(byte[] memory);
char[] AllocChar(int minimumSize);
void FreeChar(char[] memory);
///
/// Acquires a sub-segment of a larger memory allocation. Used for async sends of write-behind
/// buffers to reduce number of array segments pinned
///
/// The smallest length of the ArraySegment.Count that may be returned
/// An array segment which is a sub-block of a larger allocation
ArraySegment AllocSegment(int minimumSize);
///
/// 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.
///
/// The sub-block that was originally returned by a call to AllocSegment.
void FreeSegment(ArraySegment segment);
}
}