-
Book Overview & Buying
-
Table Of Contents
Mastering C# Concurrency
The ConcurrentStack<T> data structure is a concurrent version of a standard Stack<T> collection. It contains three main methods: Push, TryPop, and TryPeek, to append, retrieve and get the item from the collection by FILO (First In, Last Out) principle.
ConcurrentStack<T> is implemented as a singly-linked lock-free list, which makes it less interesting in terms of reviewing the implementation details. Nevertheless, it is still useful to know, and if we have to choose a concurrent data structure for a scenario where elements processing order is not important, it is preferable to use a concurrent queue since it has less performance overhead. Appending elements to the concurrent stack always leads to additional memory allocation, which can be a significant drawback in certain scenarios.
Change the font size
Change margin width
Change background colour