Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev-pomma89'
Browse files Browse the repository at this point in the history
  • Loading branch information
pomma89 committed Sep 18, 2016
2 parents a7e744c + 34d575d commit 6c7ea62
Show file tree
Hide file tree
Showing 18 changed files with 22 additions and 190 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 2 additions & 8 deletions ObjectPool.NuGet/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package>
<metadata>
<id>CodeProject.ObjectPool</id>
<version>2.1.0</version>
<version>2.1.1</version>
<title>Generic and concurrent Object Pool</title>
<authors>Ofir Makmal &lt;Ofir.Makmal@gmail.com&gt;</authors>
<owners>Alessio Parma &lt;alessio.parma@gmail.com&gt;</owners>
Expand All @@ -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.
</description>
<releaseNotes>
* 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.0.
</releaseNotes>
<summary>
A generic, concurrent, portable and flexible Object Pool for the .NET Framework.
Expand Down
110 changes: 0 additions & 110 deletions ObjectPool.UnitTests/Specialized/MemoryStreamPoolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
12 changes: 0 additions & 12 deletions ObjectPool/Specialized/IMemoryStreamPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,5 @@ public interface IMemoryStreamPool : IObjectPool<PooledMemoryStream>
/// to pool. Defaults to <see cref="SpecializedPoolConstants.DefaultMaximumMemoryStreamCapacity"/>.
/// </summary>
int MaximumMemoryStreamCapacity { get; set; }

/// <summary>
/// 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.
/// </summary>
/// <param name="buffer">The byte array that will be used as stream buffer.</param>
/// <returns>A pooled memory stream.</returns>
/// <remarks>
/// When you pass a buffer to this method, you lose the ownership of the buffer, since it
/// might be claimed by the pool itself.
/// </remarks>
PooledMemoryStream GetObject(byte[] buffer);
}
}
19 changes: 0 additions & 19 deletions ObjectPool/Specialized/MemoryStreamPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,5 @@ public int MaximumMemoryStreamCapacity
}
}
}

#pragma warning disable CC0022 // Should dispose object

/// <summary>
/// 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.
/// </summary>
/// <param name="buffer">The byte array that will be used as stream buffer.</param>
/// <returns>A pooled memory stream.</returns>
/// <remarks>
/// When you pass a buffer to this method, you lose the ownership of the buffer, since it
/// might be claimed by the pool itself.
/// </remarks>
public PooledMemoryStream GetObject(byte[] buffer) => new PooledMemoryStream(buffer)
{
Handle = this
};

#pragma warning restore CC0022 // Should dispose object
}
}
29 changes: 4 additions & 25 deletions ObjectPool/Specialized/PooledMemoryStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,11 @@ public class PooledMemoryStream : PooledObject
/// </summary>
/// <param name="capacity">The capacity of the backing stream.</param>
public PooledMemoryStream(int capacity)
: this(new TrackedMemoryStream(capacity))
{
}

/// <summary>
/// Builds a pooled memory stream using given buffer.
/// </summary>
/// <param name="buffer">The buffer.</param>
public PooledMemoryStream(byte[] buffer)
: this(new TrackedMemoryStream(buffer))
{
}

/// <summary>
/// Builds a pooled memory stream using given stream.
/// </summary>
/// <param name="trackedMemoryStream">The backing stream.</param>
private PooledMemoryStream(TrackedMemoryStream trackedMemoryStream)
{
_trackedMemoryStream = trackedMemoryStream;
_trackedMemoryStream.Parent = this;
_trackedMemoryStream = new TrackedMemoryStream(capacity)
{
Parent = this
};
}

/// <summary>
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions ObjectPool/Specialized/StringBuilderPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ public int MaximumStringBuilderCapacity
}
}

#pragma warning disable CC0022 // Should dispose object

/// <summary>
/// Returns a pooled string builder using given string as initial value.
/// </summary>
Expand All @@ -100,7 +98,5 @@ public PooledStringBuilder GetObject(string value)
psb.StringBuilder.Append(value);
return psb;
}

#pragma warning restore CC0022 // Should dispose object
}
}
2 changes: 1 addition & 1 deletion ObjectPool/doxyfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.1.1
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#---------------------------------#

# version format
version: 2.1.0.{build}
version: 2.1.1.{build}

# branches to build
branches:
Expand All @@ -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}"

Expand Down

0 comments on commit 6c7ea62

Please sign in to comment.