From 86e2a2c0dac59a14a37af07292acf383d1706a9f Mon Sep 17 00:00:00 2001 From: Alessio Parma Date: Sun, 18 Sep 2016 14:29:22 +0200 Subject: [PATCH 1/3] Removed a feature added by mistake in v2.1.0. --- CHANGELOG.md | 4 + .../Specialized/MemoryStreamPoolTests.cs | 110 ------------------ ObjectPool/Specialized/IMemoryStreamPool.cs | 12 -- ObjectPool/Specialized/MemoryStreamPool.cs | 19 --- ObjectPool/Specialized/PooledMemoryStream.cs | 29 +---- ObjectPool/Specialized/StringBuilderPool.cs | 4 - 6 files changed, 8 insertions(+), 170 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 722556a..171ec87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog for CodeProject.ObjectPool # +### v2.1.1 (2016-09-18) ### + +* BREAKING CHANGE: Removed a feature added by mistake in v2.1.0. + ### v2.1.0 (2016-09-18) ### * Changed default min and max size for MemoryStreamPool: 4KB min, 512KB max. diff --git a/ObjectPool.UnitTests/Specialized/MemoryStreamPoolTests.cs b/ObjectPool.UnitTests/Specialized/MemoryStreamPoolTests.cs index 18df709..63d63cd 100644 --- a/ObjectPool.UnitTests/Specialized/MemoryStreamPoolTests.cs +++ b/ObjectPool.UnitTests/Specialized/MemoryStreamPoolTests.cs @@ -304,116 +304,6 @@ public void CreatedAtPropertyShouldChangeUsageAfterUsage() } } - [TestCase("a&b")] - [TestCase("SNAU ORSO birretta")] - [TestCase("PU <3 PI")] - public void ShouldNotReturnToPoolWhenInitialBufferIsSmall(string text) - { - string result; - using (var pms = _memoryStreamPool.GetObject(Encoding.Default.GetBytes(text))) - { -#pragma warning disable CC0022 // Should dispose object - - var sr = new StreamReader(pms.MemoryStream); - result = sr.ReadToEnd(); - -#pragma warning restore CC0022 // Should dispose object - - pms.MemoryStream.Capacity.ShouldBeLessThan(_memoryStreamPool.MinimumMemoryStreamCapacity); - } - - result.ShouldBe(text); - - _memoryStreamPool.ObjectsInPoolCount.ShouldBe(_memoryStreamPool.MinimumPoolSize); - _memoryStreamPool.Diagnostics.ReturnedToPoolCount.ShouldBe(0); - _memoryStreamPool.Diagnostics.ObjectResetFailedCount.ShouldBe(1); - } - - [TestCase(1000)] - [TestCase(2000)] - public void ShouldNotReturnToPoolWhenInitialBufferIsLarge(int count) - { - var text = LipsumGenerator.Generate(count); - - string result; - using (var pms = _memoryStreamPool.GetObject(Encoding.Default.GetBytes(text))) - { -#pragma warning disable CC0022 // Should dispose object - - var sr = new StreamReader(pms.MemoryStream); - result = sr.ReadToEnd(); - -#pragma warning restore CC0022 // Should dispose object - - pms.MemoryStream.Capacity.ShouldBeGreaterThan(_memoryStreamPool.MaximumMemoryStreamCapacity); - } - - result.ShouldBe(text); - - _memoryStreamPool.ObjectsInPoolCount.ShouldBe(_memoryStreamPool.MinimumPoolSize); - _memoryStreamPool.Diagnostics.ReturnedToPoolCount.ShouldBe(0); - _memoryStreamPool.Diagnostics.ObjectResetFailedCount.ShouldBe(1); - } - - [TestCase(100)] - [TestCase(200)] - [TestCase(300)] - public void ShouldReturnToPoolWhenInitialBufferIsRight(int count) - { - var text = LipsumGenerator.Generate(count); - - string result; - using (var pms = _memoryStreamPool.GetObject(Encoding.Default.GetBytes(text))) - { -#pragma warning disable CC0022 // Should dispose object - - var sr = new StreamReader(pms.MemoryStream); - result = sr.ReadToEnd(); - -#pragma warning restore CC0022 // Should dispose object - - pms.MemoryStream.Capacity.ShouldBeGreaterThan(_memoryStreamPool.MinimumMemoryStreamCapacity); - pms.MemoryStream.Capacity.ShouldBeLessThan(_memoryStreamPool.MaximumMemoryStreamCapacity); - } - - result.ShouldBe(text); - - _memoryStreamPool.ObjectsInPoolCount.ShouldBe(_memoryStreamPool.MinimumPoolSize + 1); - _memoryStreamPool.Diagnostics.ReturnedToPoolCount.ShouldBe(1); - _memoryStreamPool.Diagnostics.ObjectResetFailedCount.ShouldBe(0); - } - - [TestCase(100)] - [TestCase(200)] - [TestCase(300)] - public void ManyBuffersShouldReturnToPoolWhenInitialBufferIsRightButPoolShouldNotOverflow(int count) - { - for (var i = 0; i < count; ++i) - { - var text = LipsumGenerator.Generate(300); - - string result; - using (var pms = _memoryStreamPool.GetObject(Encoding.Default.GetBytes(text))) - { -#pragma warning disable CC0022 // Should dispose object - - var sr = new StreamReader(pms.MemoryStream); - result = sr.ReadToEnd(); - -#pragma warning restore CC0022 // Should dispose object - - pms.MemoryStream.Capacity.ShouldBeGreaterThan(_memoryStreamPool.MinimumMemoryStreamCapacity); - pms.MemoryStream.Capacity.ShouldBeLessThan(_memoryStreamPool.MaximumMemoryStreamCapacity); - } - - result.ShouldBe(text); - } - - _memoryStreamPool.ObjectsInPoolCount.ShouldBe(_memoryStreamPool.MaximumPoolSize); - _memoryStreamPool.Diagnostics.ReturnedToPoolCount.ShouldBe(_memoryStreamPool.MaximumPoolSize - _memoryStreamPool.MinimumPoolSize); - _memoryStreamPool.Diagnostics.PoolOverflowCount.ShouldBe(count - (_memoryStreamPool.MaximumPoolSize - _memoryStreamPool.MinimumPoolSize)); - } - [Test] public void ShouldNotClearPoolWhenMinCapacityIsDecreased() { diff --git a/ObjectPool/Specialized/IMemoryStreamPool.cs b/ObjectPool/Specialized/IMemoryStreamPool.cs index 222d97e..009bd12 100644 --- a/ObjectPool/Specialized/IMemoryStreamPool.cs +++ b/ObjectPool/Specialized/IMemoryStreamPool.cs @@ -41,17 +41,5 @@ public interface IMemoryStreamPool : IObjectPool /// to pool. Defaults to . /// int MaximumMemoryStreamCapacity { get; set; } - - /// - /// Returns a pooled memory stream using given byte array as stream buffer. Once the object - /// is returned to the pool, the pool itself might take ownership of given buffer. - /// - /// The byte array that will be used as stream buffer. - /// A pooled memory stream. - /// - /// When you pass a buffer to this method, you lose the ownership of the buffer, since it - /// might be claimed by the pool itself. - /// - PooledMemoryStream GetObject(byte[] buffer); } } \ No newline at end of file diff --git a/ObjectPool/Specialized/MemoryStreamPool.cs b/ObjectPool/Specialized/MemoryStreamPool.cs index 93be3cf..507ce1a 100644 --- a/ObjectPool/Specialized/MemoryStreamPool.cs +++ b/ObjectPool/Specialized/MemoryStreamPool.cs @@ -86,24 +86,5 @@ public int MaximumMemoryStreamCapacity } } } - -#pragma warning disable CC0022 // Should dispose object - - /// - /// Returns a pooled memory stream using given byte array as stream buffer. Once the object - /// is returned to the pool, the pool itself might take ownership of given buffer. - /// - /// The byte array that will be used as stream buffer. - /// A pooled memory stream. - /// - /// When you pass a buffer to this method, you lose the ownership of the buffer, since it - /// might be claimed by the pool itself. - /// - public PooledMemoryStream GetObject(byte[] buffer) => new PooledMemoryStream(buffer) - { - Handle = this - }; - -#pragma warning restore CC0022 // Should dispose object } } \ No newline at end of file diff --git a/ObjectPool/Specialized/PooledMemoryStream.cs b/ObjectPool/Specialized/PooledMemoryStream.cs index 71a35a0..b3c3b08 100644 --- a/ObjectPool/Specialized/PooledMemoryStream.cs +++ b/ObjectPool/Specialized/PooledMemoryStream.cs @@ -42,27 +42,11 @@ public class PooledMemoryStream : PooledObject /// /// The capacity of the backing stream. public PooledMemoryStream(int capacity) - : this(new TrackedMemoryStream(capacity)) { - } - - /// - /// Builds a pooled memory stream using given buffer. - /// - /// The buffer. - public PooledMemoryStream(byte[] buffer) - : this(new TrackedMemoryStream(buffer)) - { - } - - /// - /// Builds a pooled memory stream using given stream. - /// - /// The backing stream. - private PooledMemoryStream(TrackedMemoryStream trackedMemoryStream) - { - _trackedMemoryStream = trackedMemoryStream; - _trackedMemoryStream.Parent = this; + _trackedMemoryStream = new TrackedMemoryStream(capacity) + { + Parent = this + }; } /// @@ -128,11 +112,6 @@ public TrackedMemoryStream(int capacity) { } - public TrackedMemoryStream(byte[] buffer) - : base(buffer) - { - } - public PooledMemoryStream Parent { get; set; } protected override void Dispose(bool disposing) diff --git a/ObjectPool/Specialized/StringBuilderPool.cs b/ObjectPool/Specialized/StringBuilderPool.cs index eaad79b..54bfcef 100644 --- a/ObjectPool/Specialized/StringBuilderPool.cs +++ b/ObjectPool/Specialized/StringBuilderPool.cs @@ -87,8 +87,6 @@ public int MaximumStringBuilderCapacity } } -#pragma warning disable CC0022 // Should dispose object - /// /// Returns a pooled string builder using given string as initial value. /// @@ -100,7 +98,5 @@ public PooledStringBuilder GetObject(string value) psb.StringBuilder.Append(value); return psb; } - -#pragma warning restore CC0022 // Should dispose object } } \ No newline at end of file From 8a37b794f1813aa7092caf2bd77dcbbadf8d35b4 Mon Sep 17 00:00:00 2001 From: Alessio Parma Date: Sun, 18 Sep 2016 14:32:05 +0200 Subject: [PATCH 2/3] v2.1.1 --- ObjectPool.NuGet/Package.nuspec | 10 ++-------- ObjectPool/doxyfile.txt | 2 +- .../ObjectPool.NET35/Properties/AssemblyInfo.cs | 2 +- .../ObjectPool.NET40/Properties/AssemblyInfo.cs | 2 +- .../ObjectPool.NET45/Properties/AssemblyInfo.cs | 2 +- .../ObjectPool.NET46/Properties/AssemblyInfo.cs | 2 +- .../ObjectPool.NETSTD11/Properties/AssemblyInfo.cs | 2 +- .../ObjectPool.NETSTD13/Properties/AssemblyInfo.cs | 2 +- .../ObjectPool.Portable/Properties/AssemblyInfo.cs | 2 +- README.md | 2 +- VERSION.md | 2 +- appveyor.yml | 4 ++-- 12 files changed, 14 insertions(+), 20 deletions(-) diff --git a/ObjectPool.NuGet/Package.nuspec b/ObjectPool.NuGet/Package.nuspec index eac7806..67a9092 100644 --- a/ObjectPool.NuGet/Package.nuspec +++ b/ObjectPool.NuGet/Package.nuspec @@ -3,7 +3,7 @@ CodeProject.ObjectPool - 2.1.0 + 2.1.1 Generic and concurrent Object Pool Ofir Makmal <Ofir.Makmal@gmail.com> Alessio Parma <alessio.parma@gmail.com> @@ -18,13 +18,7 @@ Of course, all modified source code is freely available at the project URL of th Many thanks to Ofir Makmal for his great work. -* Changed default min and max size for MemoryStreamPool: 4KB min, 512KB max. -* Changed default min and max size for StringBuilderPool: 4K char min, 512K char max. -* Created two ad-hoc interfaces for specialized pools. -* BREAKING CHANGE: Moved static properties which controlled specialized pool sizes to the new interfaces. -* Updated Thrower. -* ObjectPool did not respect min pool size bound. Now it does. -* When min or max capacity of specialized pools is changed, pool is cleared, if necessary. +* BREAKING CHANGE: Removed a feature added by mistake in v2.1.1. A generic, concurrent, portable and flexible Object Pool for the .NET Framework. diff --git a/ObjectPool/doxyfile.txt b/ObjectPool/doxyfile.txt index 7ad1582..bda490f 100644 --- a/ObjectPool/doxyfile.txt +++ b/ObjectPool/doxyfile.txt @@ -38,7 +38,7 @@ PROJECT_NAME = "Generic and concurrent Object Pool" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 2.1.0 +PROJECT_NUMBER = 2.1.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/Platform Specific/ObjectPool.NET35/Properties/AssemblyInfo.cs b/Platform Specific/ObjectPool.NET35/Properties/AssemblyInfo.cs index 062783b..bbb41c1 100644 --- a/Platform Specific/ObjectPool.NET35/Properties/AssemblyInfo.cs +++ b/Platform Specific/ObjectPool.NET35/Properties/AssemblyInfo.cs @@ -35,7 +35,7 @@ // You can specify all the values or you can default the Build and Revision Numbers by using the '*' // as shown below: [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.1.0")] +[assembly: AssemblyFileVersion("2.1.1")] // Common Language Specification (CLS) compliance generally refers to the claim that CLS rules and // restrictions are being followed. diff --git a/Platform Specific/ObjectPool.NET40/Properties/AssemblyInfo.cs b/Platform Specific/ObjectPool.NET40/Properties/AssemblyInfo.cs index 062783b..bbb41c1 100644 --- a/Platform Specific/ObjectPool.NET40/Properties/AssemblyInfo.cs +++ b/Platform Specific/ObjectPool.NET40/Properties/AssemblyInfo.cs @@ -35,7 +35,7 @@ // You can specify all the values or you can default the Build and Revision Numbers by using the '*' // as shown below: [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.1.0")] +[assembly: AssemblyFileVersion("2.1.1")] // Common Language Specification (CLS) compliance generally refers to the claim that CLS rules and // restrictions are being followed. diff --git a/Platform Specific/ObjectPool.NET45/Properties/AssemblyInfo.cs b/Platform Specific/ObjectPool.NET45/Properties/AssemblyInfo.cs index 062783b..bbb41c1 100644 --- a/Platform Specific/ObjectPool.NET45/Properties/AssemblyInfo.cs +++ b/Platform Specific/ObjectPool.NET45/Properties/AssemblyInfo.cs @@ -35,7 +35,7 @@ // You can specify all the values or you can default the Build and Revision Numbers by using the '*' // as shown below: [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.1.0")] +[assembly: AssemblyFileVersion("2.1.1")] // Common Language Specification (CLS) compliance generally refers to the claim that CLS rules and // restrictions are being followed. diff --git a/Platform Specific/ObjectPool.NET46/Properties/AssemblyInfo.cs b/Platform Specific/ObjectPool.NET46/Properties/AssemblyInfo.cs index 062783b..bbb41c1 100644 --- a/Platform Specific/ObjectPool.NET46/Properties/AssemblyInfo.cs +++ b/Platform Specific/ObjectPool.NET46/Properties/AssemblyInfo.cs @@ -35,7 +35,7 @@ // You can specify all the values or you can default the Build and Revision Numbers by using the '*' // as shown below: [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.1.0")] +[assembly: AssemblyFileVersion("2.1.1")] // Common Language Specification (CLS) compliance generally refers to the claim that CLS rules and // restrictions are being followed. diff --git a/Platform Specific/ObjectPool.NETSTD11/Properties/AssemblyInfo.cs b/Platform Specific/ObjectPool.NETSTD11/Properties/AssemblyInfo.cs index 062783b..bbb41c1 100644 --- a/Platform Specific/ObjectPool.NETSTD11/Properties/AssemblyInfo.cs +++ b/Platform Specific/ObjectPool.NETSTD11/Properties/AssemblyInfo.cs @@ -35,7 +35,7 @@ // You can specify all the values or you can default the Build and Revision Numbers by using the '*' // as shown below: [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.1.0")] +[assembly: AssemblyFileVersion("2.1.1")] // Common Language Specification (CLS) compliance generally refers to the claim that CLS rules and // restrictions are being followed. diff --git a/Platform Specific/ObjectPool.NETSTD13/Properties/AssemblyInfo.cs b/Platform Specific/ObjectPool.NETSTD13/Properties/AssemblyInfo.cs index 062783b..bbb41c1 100644 --- a/Platform Specific/ObjectPool.NETSTD13/Properties/AssemblyInfo.cs +++ b/Platform Specific/ObjectPool.NETSTD13/Properties/AssemblyInfo.cs @@ -35,7 +35,7 @@ // You can specify all the values or you can default the Build and Revision Numbers by using the '*' // as shown below: [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.1.0")] +[assembly: AssemblyFileVersion("2.1.1")] // Common Language Specification (CLS) compliance generally refers to the claim that CLS rules and // restrictions are being followed. diff --git a/Platform Specific/ObjectPool.Portable/Properties/AssemblyInfo.cs b/Platform Specific/ObjectPool.Portable/Properties/AssemblyInfo.cs index 062783b..bbb41c1 100644 --- a/Platform Specific/ObjectPool.Portable/Properties/AssemblyInfo.cs +++ b/Platform Specific/ObjectPool.Portable/Properties/AssemblyInfo.cs @@ -35,7 +35,7 @@ // You can specify all the values or you can default the Build and Revision Numbers by using the '*' // as shown below: [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.1.0")] +[assembly: AssemblyFileVersion("2.1.1")] // Common Language Specification (CLS) compliance generally refers to the claim that CLS rules and // restrictions are being followed. diff --git a/README.md b/README.md index 0a63978..3623801 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A generic, concurrent, portable and flexible Object Pool for the .NET Framework, ## Summary ## -* Latest release version: `v2.1.0` +* Latest release version: `v2.1.1` * Build status on [AppVeyor](https://ci.appveyor.com): [![Build status](https://ci.appveyor.com/api/projects/status/r4qnqaqj9ri6cicn?svg=true)](https://ci.appveyor.com/project/pomma89/objectpool) * [Doxygen](http://www.stack.nl/~dimitri/doxygen/index.html) documentation: + [HTML](https://goo.gl/RVA7mV) diff --git a/VERSION.md b/VERSION.md index 7ec1d6d..3e3c2f1 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1 +1 @@ -2.1.0 +2.1.1 diff --git a/appveyor.yml b/appveyor.yml index a084808..fc836ef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,7 @@ #---------------------------------# # version format -version: 2.1.0.{build} +version: 2.1.1.{build} # branches to build branches: @@ -25,7 +25,7 @@ branches: assembly_info: patch: true file: AssemblyInfo.* - assembly_version: "2.1.0.{build}" + assembly_version: "2.1.1.{build}" assembly_file_version: "{version}" assembly_informational_version: "{version}" From 34d575de64839d1444379e7033dd0d2ac4ce5c4a Mon Sep 17 00:00:00 2001 From: Alessio Parma Date: Sun, 18 Sep 2016 14:46:21 +0200 Subject: [PATCH 3/3] ... --- ObjectPool.NuGet/Package.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ObjectPool.NuGet/Package.nuspec b/ObjectPool.NuGet/Package.nuspec index 67a9092..cb157fc 100644 --- a/ObjectPool.NuGet/Package.nuspec +++ b/ObjectPool.NuGet/Package.nuspec @@ -18,7 +18,7 @@ Of course, all modified source code is freely available at the project URL of th Many thanks to Ofir Makmal for his great work. -* BREAKING CHANGE: Removed a feature added by mistake in v2.1.1. +* BREAKING CHANGE: Removed a feature added by mistake in v2.1.0. A generic, concurrent, portable and flexible Object Pool for the .NET Framework.