Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go Channels

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

Go Channels

Avatar for Sinan Ülker

Sinan Ülker

January 26, 2019
Tweet

More Decks by Sinan Ülker

Other Decks in Technology

Transcript

  1. What is Concurrency? ◆ Ability of a computer to deal

    with multiple things at once. ◆ A way to structure software. ◆ Enables parallelism.
  2. Concurrency in GO: Goroutines ➔ use ‘go’ keyword to create

    goroutines ➔ It's not a thread. ➔ Very cheap compared to threads
  3. Goroutines vs Threads • managed by go runtime and has

    no hardware dependencies. • have 2KB of stack size; can grow up dynamically if needed by using heap storage • uses channels to communicate with other • Threads are managed by kernel and has hardware dependencies. • Threads generally have fixed stack size of 1-2MB • There is no easy communication between threads, inter-thread communication
  4. Further Reading • https://www.youtube.com/watch?v=f6kdp27TYZs (Google I/O 2012 - Go Concurrency

    Patterns) • https://medium.com/rungo/achieving-concurrency-in-go-3f84cbf870ca • https://medium.com/@trevor4e/learning-gos-concurrency-through-illustrations-8c4aff603b3 • https://dougrichardson.org/2016/01/23/go-memory-allocations.html • https://stackoverflow.com/questions/25795131/do-golang-channels-maintain-order