Skip to content

chapsuk/wait

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

What

Sugared sync.WaitGroup

Why

LGTM

Example

package main

import (
    "context"
    "fmt"

    "github.com/chapsuk/wait"
)

func do()                               { fmt.Print("do\n") }
func doWithArgs(i, j int)               { fmt.Printf("doWith args: %d %d\n", i, j) }
func doWithContext(ctx context.Context) { fmt.Printf("doWithContext\n") }

func main() {
    wg := wait.Group{}

    wg.Add(do)
    wg.Add(func() {
        doWithArgs(1, 2)
    })
    wg.AddMany(10, do)
    wg.AddWithContext(context.TODO(), doWithContext)
    wg.AddManyWithContext(context.TODO(), 10, doWithContext)
    wg.Wait()
}