Skip to content

blizzy78/goroutine

Repository files navigation

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 := goroutine.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.

About

Go package to manage goroutines and facilitate their graceful shutdown.

Topics

Resources

License

Stars

Watchers

Forks

Languages