You've already forked go-profiler-notes
mirror of
https://github.com/DataDog/go-profiler-notes.git
synced 2025-07-12 23:50:13 +02:00
Initial work on new guide
This commit is contained in:
28
guide/heap.go
Normal file
28
guide/heap.go
Normal file
@ -0,0 +1,28 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
sum int32
|
||||
wg = &sync.WaitGroup{}
|
||||
)
|
||||
|
||||
wg.Add(2)
|
||||
go add(&sum, 23, wg)
|
||||
go add(&sum, 42, wg)
|
||||
wg.Wait()
|
||||
|
||||
fmt.Println(sum)
|
||||
}
|
||||
|
||||
func add(dst *int32, delta int32, wg *sync.WaitGroup) {
|
||||
atomic.AddInt32(dst, delta)
|
||||
wg.Done()
|
||||
}
|
Reference in New Issue
Block a user