Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Remove MemoryPool and fix System.Buffers version #2086

Merged
merged 5 commits into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DotnetCLIVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.300-preview2-008019
2.1.300-preview2-008022
2 changes: 1 addition & 1 deletion SharedRuntimeVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0-preview2-26124-07
2.1.0-preview2-26129-05
1 change: 1 addition & 0 deletions scripts/update-dependencies/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private static IEnumerable<IDependencyUpdater> GetUpdaters()
yield return CreateRegexPropertyUpdater(config.DependencyFilePath, "SystemCompilerServicesUnsafeVersion", "System.Runtime.CompilerServices.Unsafe");
yield return CreateRegexPropertyUpdater(config.DependencyFilePath, "SystemMemoryVersion", "System.Memory");
yield return CreateRegexPropertyUpdater(config.DependencyFilePath, "SystemNumericsVectorsVersion", "System.Numerics.Vectors");
yield return CreateRegexPropertyUpdater(config.DependencyFilePath, "SystemBuffersVersion", "System.Buffers");
yield return CreateFileUpdater(config.CLIVersionFilePath, "Microsoft.DotNet.Cli.Utils");

// Temporary workaround until CLI, Core-Setup, CoreFx are all in sync with the shared runtime.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected override void Dispose(bool disposing)

public override OwnedMemory<byte> Rent(int numberOfBytes = DefaultSize)
{
if (numberOfBytes == AnySize) numberOfBytes = DefaultSize;
if (numberOfBytes == -1) numberOfBytes = DefaultSize;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still have a private constant for documentation purposes?

if (numberOfBytes < 1 || numberOfBytes > MaxBufferSize) throw new ArgumentOutOfRangeException(nameof(numberOfBytes));
if (numberOfBytes > _bufferSize) new NotSupportedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<RootNamespace></RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Buffers" Version="$(CoreFxStableVersion)" />
<PackageReference Include="System.Buffers" Version="$(SystemBuffersVersion)" />
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="$(SystemCompilerServicesUnsafeVersion)" />
<PackageReference Include="System.ValueTuple" Version="$(CoreFxStableVersion)" />
Expand Down

This file was deleted.

29 changes: 0 additions & 29 deletions src/System.Buffers.Primitives/System/Buffers/Pooling/MemoryPool.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public RioMemoryPool(Action<RioMemoryPoolSlab> allocationCallback = null, Action
_slabDeallocationCallback = deallocationCallback;
}

public override OwnedMemory<byte> Rent(int size = AnySize)
public override OwnedMemory<byte> Rent(int size = -1)
{
if (size == AnySize) size = _blockLength;
if (size == -1) size = _blockLength;
else if (size > _blockLength)
{
RioPipelinesThrowHelper.ThrowArgumentOutOfRangeException_BufferRequestTooLarge(_blockLength);
Expand Down
4 changes: 2 additions & 2 deletions src/System.IO.Pipelines/System/Buffers/MemoryPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public class MemoryPool : MemoryPool<byte>
/// </summary>
private bool _disposedValue = false; // To detect redundant calls

public override OwnedMemory<byte> Rent(int size = AnySize)
public override OwnedMemory<byte> Rent(int size = -1)
{
if (size == AnySize) size = _blockLength;
if (size == -1) size = _blockLength;
else if (size > _blockLength)
{
PipelinesThrowHelper.ThrowArgumentOutOfRangeException_BufferRequestTooLarge(_blockLength);
Expand Down
2 changes: 1 addition & 1 deletion src/System.IO.Pipelines/System/IO/Pipelines/PipeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public PipeOptions(
long resumeWriterThreshold = 0,
int minimumSegmentSize = 2048)
{
Pool = pool ?? MemoryPool.Default;
Pool = pool ?? MemoryPool.Shared;
ReaderScheduler = readerScheduler;
WriterScheduler = writerScheduler;
PauseWriterThreshold = pauseWriterThreshold;
Expand Down
2 changes: 1 addition & 1 deletion src/System.Text.Json/System/Text/Json/JsonParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private enum JsonTokenType
public JsonObject Parse(ReadOnlySpan<byte> utf8Json, MemoryPool<byte> pool = null)
{
_pool = pool;
if (_pool == null) _pool = MemoryPool<byte>.Default;
if (_pool == null) _pool = MemoryPool<byte>.Shared;
_scratchManager = _pool.Rent(utf8Json.Length * 4);
_scratchMemory = _scratchManager.Memory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void OwnedArrayReferenceTests()
public void PooledBufferReferenceTests()
{
BufferReferenceTests.TestOwnedBuffer(() => {
return MemoryPool<byte>.Default.Rent(1000);
return MemoryPool<byte>.Shared.Rent(1000);
});
}

Expand Down
9 changes: 5 additions & 4 deletions tools/dependencies.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project>
<PropertyGroup>
<RuntimeFrameworkVersion>2.1.0-preview2-26124-07</RuntimeFrameworkVersion>
<RuntimeFrameworkVersion>2.1.0-preview2-26129-05</RuntimeFrameworkVersion>
<CoreFxStableVersion>4.3.0</CoreFxStableVersion>
<RoslynVersion>2.6.0-beta3-62316-02</RoslynVersion>
<SystemMemoryVersion>4.5.0-preview2-26125-06</SystemMemoryVersion>
<SystemCompilerServicesUnsafeVersion>4.5.0-preview2-26125-06</SystemCompilerServicesUnsafeVersion>
<SystemNumericsVectorsVersion>4.5.0-preview2-26125-06</SystemNumericsVectorsVersion>
<SystemMemoryVersion>4.5.0-preview2-26127-04</SystemMemoryVersion>
<SystemCompilerServicesUnsafeVersion>4.5.0-preview2-26127-04</SystemCompilerServicesUnsafeVersion>
<SystemNumericsVectorsVersion>4.5.0-preview2-26127-04</SystemNumericsVectorsVersion>
<SystemBuffersVersion>4.5.0-preview2-26127-04</SystemBuffersVersion>
<LibuvVersion>1.9.1</LibuvVersion>
<TestSdkVersion>15.0.0</TestSdkVersion>
<XunitVersion>2.2.0</XunitVersion>
Expand Down