github.com/omniscale/go-osm@v0.3.1/parser/pbf/barrier_test.go (about) 1 package pbf 2 3 import ( 4 "testing" 5 ) 6 7 func TestBarrier(t *testing.T) { 8 done := make(chan bool) 9 check := int32(0) 10 bar := newBarrier(func() { 11 done <- true 12 check = 1 13 }) 14 bar.add(2) 15 16 wait := func() { 17 if check != 0 { 18 panic("check set") 19 } 20 bar.doneWait() 21 if check != 1 { 22 panic("check not set") 23 } 24 } 25 go wait() 26 go wait() 27 28 <-done 29 30 // does not wait/block 31 bar.doneWait() 32 }