Skip to content

Commit

Permalink
move back to stack in buffer manager
Browse files Browse the repository at this point in the history
fix error from putting licenses in
  • Loading branch information
gregoryyoung committed Sep 20, 2012
1 parent b3b7f3f commit 548b2e7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/EventStore/EventStore.BufferManagement/BufferManager.cs
Expand Up @@ -32,9 +32,9 @@ public class BufferManager
private readonly bool _allowedToCreateMemory;

#if __MonoCS__
private readonly Common.ConcurrentCollections.ConcurrentQueue<ArraySegment<byte>> _buffers = new Common.ConcurrentCollections.ConcurrentQueue<ArraySegment<byte>>();
private readonly Common.ConcurrentCollections.ConcurrentStack<ArraySegment<byte>> _buffers = new Common.ConcurrentCollections.ConcurrentStack<ArraySegment<byte>>();
#else
private readonly System.Collections.Concurrent.ConcurrentQueue<ArraySegment<byte>> _buffers = new System.Collections.Concurrent.ConcurrentQueue<ArraySegment<byte>>();
private readonly System.Collections.Concurrent.ConcurrentStack<ArraySegment<byte>> _buffers = new System.Collections.Concurrent.ConcurrentStack<ArraySegment<byte>>();
#endif

private readonly List<byte[]> _segments;
Expand Down Expand Up @@ -157,7 +157,7 @@ private void CreateNewSegment(bool forceCreation)
for (int i = 0; i < _segmentChunks; i++)
{
var chunk = new ArraySegment<byte>(bytes, i * _chunkSize, _chunkSize);
_buffers.Enqueue(chunk);
_buffers.Push(chunk);
}

Log.Info("Segments count: {0}, buffers count: {1}, should be when full: {2}",
Expand All @@ -181,7 +181,7 @@ public ArraySegment<byte> CheckOut()
while (trial < TrialsCount)
{
ArraySegment<byte> result;
if (_buffers.TryDequeue(out result))
if (_buffers.TryPop(out result))
return result;
CreateNewSegment(false);
trial++;
Expand All @@ -208,7 +208,7 @@ public IEnumerable<ArraySegment<byte>> CheckOut(int toGet)
ArraySegment<byte> piece;
while (totalReceived < toGet)
{
if (!_buffers.TryDequeue(out piece))
if (!_buffers.TryPop(out piece))
break;
result[totalReceived] = piece;
++totalReceived;
Expand All @@ -232,7 +232,7 @@ public IEnumerable<ArraySegment<byte>> CheckOut(int toGet)
public void CheckIn(ArraySegment<byte> buffer)
{
CheckBuffer(buffer);
_buffers.Enqueue(buffer);
_buffers.Push(buffer);
}

/// <summary>
Expand All @@ -251,7 +251,7 @@ public void CheckIn(IEnumerable<ArraySegment<byte>> buffersToReturn)
foreach (var buf in buffersToReturn)
{
CheckBuffer(buf);
_buffers.Enqueue(buf);
_buffers.Push(buf);
}
}

Expand Down
Expand Up @@ -24,7 +24,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// using System;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down
Expand Up @@ -24,7 +24,8 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// using System;

using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down
Expand Up @@ -24,7 +24,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// using System;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down

0 comments on commit 548b2e7

Please sign in to comment.