Skip to content

javidnia/golang-concurrency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

golang-concurrency

Concurrency model in use: Communicating Sequential Processes (CSP) it means you just write your process as a sequential code, i.e. forget about parallelism while coding. You don’t have shared state! Instead of sharing you communicate the data with other processes (over channels)

Select statement

Channels Pitfalls

  • Passing pointers to channels can cause race condition
  • As channels work with copies of data, passing them large data chunks can cause performance issues
  • Channels can create deadlocks
  • Don’t use channels in front of naturally shared structures like caches or registries, because channels are about not sharing (i.e. the CSP concurrency model). - In such cases you need to use the sync and sync.atomic packages.

Patterns for lock-less programming

Guidelines for non-blocking code

  • Avoid changing two thing at a time
  • Avoid blocking
  • Avoid race conditions
  • Use channels to avoid sharing state
  • When channels don't work use sync package

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages