mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
32 lines
405 B
Go
32 lines
405 B
Go
package syncx
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
func TestDoneChanClose(t *testing.T) {
|
|
doneChan := NewDoneChan()
|
|
|
|
for i := 0; i < 5; i++ {
|
|
doneChan.Close()
|
|
}
|
|
}
|
|
|
|
func TestDoneChanDone(t *testing.T) {
|
|
var waitGroup sync.WaitGroup
|
|
doneChan := NewDoneChan()
|
|
|
|
waitGroup.Add(1)
|
|
go func() {
|
|
<-doneChan.Done()
|
|
waitGroup.Done()
|
|
}()
|
|
|
|
for i := 0; i < 5; i++ {
|
|
doneChan.Close()
|
|
}
|
|
|
|
waitGroup.Wait()
|
|
}
|