github.com/azazeal/pause

pause implements a way to suspend execution until a Context is either done or a timeout has been reached.


Keywords
concurrency, concurrency-patterns, go
License
MIT
Install
go get github.com/azazeal/pause

Documentation

Build Status Coverage Report Go Reference

pause

Package pause implements a method which suspends execution until its given Context is done or it's waited its given timeout.

Usage

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/azazeal/pause"
)

func main() {
	pause.For(context.TODO(), time.Second)
	fmt.Println("about a second elapsed since we called pause.For")

	ctx, cancel := context.WithCancel(context.TODO())
	cancel()
	pause.For(ctx, time.Hour)
	fmt.Println("almost no time elapsed since we called pause.For")
}