VisualStudioFeeds

All Visual Studio blogs in one place

AddThis Social Bookmark Button
The first concurrent collection we'll look at is ConcurrentStack. This is conceptually the same as System.Collections.Generic.Stack, but is geared towards occasional concurrent modifications. Now, in these posts I won't be looking to explain what every method does; just like my other explorations of various collection types, I'll be concentrating on the core implementation and concepts used by the collections, and glossing over the more sordid implementation details and scaffolding required to support an ICollection. So, without further ado, let's get started: ConcurrentStack There are three basic operations you can perform on a stack: Push: Push a new value onto the top of the stack TryPeek: Peeking
at the top value. In ConcurrentStack, this is quite a simple method. TryPop: Popping the top value off the stack ConcurrentStack supplements these with PushRange and TryPopRange for pushing and popping an array of values, ToArray, and the standard ICollection methods. The stack is implemented as a singly-linked list, with nodes represented by the ConcurrentStack.Node private class: private class Node { internal T m_Value; internal Node m_Next; } The top of the stack is referenced by the volatile m_head variable. An empty stack is represented by a null value in m_head. For example, if you push the integers 1, 2...(Read whole news on source site)

Search

Subscribe

Enter your email address:

Delivered by FeedBurner

Increase your website traffic with Attracta.com

Contact

Email:
Subject:
Message:
Anti-spam: How many eyes has a typical person?

Follow us on FB

Home : Blog List : Simon Cooper : Inside the Concurrent Collections: ConcurrentStack