package
0.0.0-20250206045204-45fcc3025d35
Repository: https://github.com/romangurevitch/concurrencyworkshop.git
Documentation: pkg.go.dev

# README

Understanding Go's runtime Package: Gosched

The runtime package in Go provides the Gosched function, yielding the processor to allow other goroutines to execute.

drawing

Table of Contents

  1. Introduction to Gosched
  2. Usage of Gosched
  3. Use Cases
  4. Common Pitfalls
  5. Best Practices
  6. Resources

Introduction to Gosched

runtime.Gosched hints the scheduler to pause the current goroutine and give other goroutines a chance to run.

Usage of Gosched

runtime.Gosched()

Examples and tests

See package

Use Cases

  • Improving concurrency in CPU-bound programs.
  • Preventing long-running goroutines from starving others.

Common Pitfalls

  • Overuse can lead to performance degradation.
  • Not a substitute for proper goroutine synchronisation.

Best Practices

  • Use sparingly and understand the implications on your program's concurrency.

Resources