diff --git a/src/EventStore/EventStore.BufferManagement/BufferManager.cs b/src/EventStore/EventStore.BufferManagement/BufferManager.cs index 4135e03407d..01d7b4d0236 100644 --- a/src/EventStore/EventStore.BufferManagement/BufferManager.cs +++ b/src/EventStore/EventStore.BufferManagement/BufferManager.cs @@ -32,9 +32,9 @@ public class BufferManager private readonly bool _allowedToCreateMemory; #if __MonoCS__ - private readonly Common.ConcurrentCollections.ConcurrentQueue> _buffers = new Common.ConcurrentCollections.ConcurrentQueue>(); + private readonly Common.ConcurrentCollections.ConcurrentStack> _buffers = new Common.ConcurrentCollections.ConcurrentStack>(); #else - private readonly System.Collections.Concurrent.ConcurrentQueue> _buffers = new System.Collections.Concurrent.ConcurrentQueue>(); + private readonly System.Collections.Concurrent.ConcurrentStack> _buffers = new System.Collections.Concurrent.ConcurrentStack>(); #endif private readonly List _segments; @@ -157,7 +157,7 @@ private void CreateNewSegment(bool forceCreation) for (int i = 0; i < _segmentChunks; i++) { var chunk = new ArraySegment(bytes, i * _chunkSize, _chunkSize); - _buffers.Enqueue(chunk); + _buffers.Push(chunk); } Log.Info("Segments count: {0}, buffers count: {1}, should be when full: {2}", @@ -181,7 +181,7 @@ public ArraySegment CheckOut() while (trial < TrialsCount) { ArraySegment result; - if (_buffers.TryDequeue(out result)) + if (_buffers.TryPop(out result)) return result; CreateNewSegment(false); trial++; @@ -208,7 +208,7 @@ public IEnumerable> CheckOut(int toGet) ArraySegment piece; while (totalReceived < toGet) { - if (!_buffers.TryDequeue(out piece)) + if (!_buffers.TryPop(out piece)) break; result[totalReceived] = piece; ++totalReceived; @@ -232,7 +232,7 @@ public IEnumerable> CheckOut(int toGet) public void CheckIn(ArraySegment buffer) { CheckBuffer(buffer); - _buffers.Enqueue(buffer); + _buffers.Push(buffer); } /// @@ -251,7 +251,7 @@ public void CheckIn(IEnumerable> buffersToReturn) foreach (var buf in buffersToReturn) { CheckBuffer(buf); - _buffers.Enqueue(buf); + _buffers.Push(buf); } } diff --git a/src/EventStore/EventStore.ClientAPI/Common/ConcurrentCollections/ConcurrentQueue.cs b/src/EventStore/EventStore.ClientAPI/Common/ConcurrentCollections/ConcurrentQueue.cs index f97f28f4515..e51bd518aea 100644 --- a/src/EventStore/EventStore.ClientAPI/Common/ConcurrentCollections/ConcurrentQueue.cs +++ b/src/EventStore/EventStore.ClientAPI/Common/ConcurrentCollections/ConcurrentQueue.cs @@ -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; diff --git a/src/EventStore/EventStore.Common/ConcurrentCollections/ConcurrentQueue.cs b/src/EventStore/EventStore.Common/ConcurrentCollections/ConcurrentQueue.cs index 01e1a847b86..fc874054002 100644 --- a/src/EventStore/EventStore.Common/ConcurrentCollections/ConcurrentQueue.cs +++ b/src/EventStore/EventStore.Common/ConcurrentCollections/ConcurrentQueue.cs @@ -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; diff --git a/src/EventStore/EventStore.Common/ConcurrentCollections/ConcurrentStack.cs b/src/EventStore/EventStore.Common/ConcurrentCollections/ConcurrentStack.cs index 6f62cde26ae..6280028bb94 100644 --- a/src/EventStore/EventStore.Common/ConcurrentCollections/ConcurrentStack.cs +++ b/src/EventStore/EventStore.Common/ConcurrentCollections/ConcurrentStack.cs @@ -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;