Below you will find pages that utilize the taxonomy term “Concurrency”
Go Concurrency 2.5 - Patterns and Idioms | Fan Out Fan In
So far we have discussed how Pipelines pattern can be leveraged to re-use and compose programs together. But what if I told you that we can leverage performance/speed gains by utilising Pipelines to process streams in parallel? Isn’t that the general idea of concurrency? Let’s do a simple program to find prime numbers and then let’s compare it with its Fan Out Fan In equivalent.
I am going to use testing package in this case to benchmark performance and compare them later.
Published on Mon, February 5, 2024
Go Concurrency 2.4 - Patterns and Idioms | Generators
Generator pattern is an effective way to handle conversion of concrete slice/array types to a data stream in the for of channels. These become absolutely handy when you start working with sync primitives in Go. Using this pattern also helps in predictability and readability across application.
Published on Tue, October 24, 2023
Go Concurrency 2.3 - Patterns and Idioms | Pipelines
Pipeline design pattern is not limited to concurrency and is something that every programmer has followed or implemented, even if unknowingly. A pipeline could contain one or more stages, ideally limiting single responsibility to each stage. This allows different stages to be rearranged, to be added or removed.
Published on Sun, October 1, 2023
Go Concurrency 2.1 - Patterns and Idioms | Fundamentals
In this post we talk about some of the common patterns used in Go community that are going to prove handy when working with goroutines. The topics covered are Confinement, Infinite for loop with exit case, Loop with default case and Loop with Range and the default case pattern.
Published on Tue, August 8, 2023
Go Concurrency 1.3 - Sync Package | Channels & Select
In this post I talk about the type
Channels
and Select
available under the sync package. While Channels
can be used for both communication between concurrent processes, they can also be used in synchronisation by sharing the memory address. Select
allows you to pseudo-randomly resolve one of the available/ready case.
Published on Tue, August 1, 2023
Go Concurrency 1.2 - Sync Package | Once & Pool
Continuing the sync package series, in this post I talk about the type
sync.Once
and sync.Pool
available under the sync package. While sync.Once
offers a once.Do(func() {})
signature that is perfect for initialising most of the clients in your application. While sync.Pool{New: func() interface{}}
, lets you do things like warming up, managing and creation of pool of resources.
Published on Mon, July 24, 2023
Go Concurrency 1.1 - Sync Package | WaitGroup & Mutex
Memory access synchronisation is one of the popular ways to achieve concurrency in various languages.
Sync
package is one of the major difference between these languages and Go. The package provides you new set of concurrency primitives with wide abilities on top of the memory access synchronisation primitives. I am going to briefly talk about some commonly used tools from this package.
Published on Mon, July 17, 2023