Skip to content

BrianGreenhill/groupcount

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Group Count

Group Count is a waitgroup that exposes its atomic counter.

Usage

package main

import (
    "fmt"
    "time"

    "github.com/briangreenhill/groupcount"
)

func main() {
    var wg groupcount.WaitGroup

    fmt.Println("init:", wg.Count())
    wg.Add(1)
    fmt.Println("before:", wg.Count())
    go func() {
        defer wg.Done()
        // do stuff
        time.Sleep(time.Second * 5)
    }()
    wg.Wait()
    fmt.Println("after:", wg.Count())
}