gitee.com/sy_183/go-common@v1.0.5-0.20231205030221-958cfe129b47/ipc/cgo/sem/sem_test.go (about)

     1  package sem
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestSem(t *testing.T) {
     9  	var sem Sem
    10  	if err := sem.Init(0, 2); err != nil {
    11  		panic(err)
    12  	}
    13  	fmt.Println(sem.GetValue())
    14  	fmt.Println(sem.TryWait())
    15  	fmt.Println(sem.TryWait())
    16  	fmt.Println(sem.TryWait())
    17  }