Categorygithub.com/blizzy78/goroutine
repositorypackage
0.2.0
Repository: https://github.com/blizzy78/goroutine.git
Documentation: pkg.go.dev

# README

GoDoc

goroutine

A Go package that provides a simple way to manage goroutines and facilitate their graceful shutdown.

import "github.com/blizzy78/goroutine"

Code example

// This function does the actual work.
// In this example, we're not using the Context, but you really always should.
worker := func(_ context.Context) {
	time.Sleep(100 * time.Millisecond)
}

goroutines := New()

// Start a new goroutine.
goroutines.Go(context.Background(), worker)

// Cancel all goroutines' contexts, and wait for them to finish.
_ = goroutines.CancelAll(context.Background(), true)

License

This package is licensed under the MIT license.