Implementing a Concurrent Set in Go – Part III

In the previous part of this series, we studied the Coarse-Grained Synchronization approach to run concurrent operations in our Set. We concluded that it’s a correct and reliable implementation, but it can suffer from contention when the concurrency levels are high. In this third part, we’ll review the Fine-Grained Synchronization approach. Unlike Coarse-Grained, in which we have… Continue reading Implementing a Concurrent Set in Go – Part III

Implementing a concurrent Set in Go – Part II

In the first part of this series, we reviewed the basic structure for a list-based Set. We defined three methods to interact with the Set: Add(), Remove() and Contains().  Even though this implementation works fine for one goroutine, it didn’t work correctly for concurrent threads modifying the list. Since the algorithm to traverse the linked list uses two pointers that… Continue reading Implementing a concurrent Set in Go – Part II

Implementing a concurrent Set in Go – Part I

The purpose of this series is not to present a production-ready data structure, but to study different locking strategies when building one. We will review three ways to implement a concurrent sorted Set using a Linked list. Sets are well-known data structures, so we can focus on the concurrency aspects and briefly describe the implementation.… Continue reading Implementing a concurrent Set in Go – Part I