github.com/GoWebProd/gip@v0.0.0-20230623090727-b60d41d5d320/futex/futex_test.go (about)

     1  package futex
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  )
     7  
     8  func TestFutex(t *testing.T) {
     9  	var value uint32
    10  
    11  	go func() {
    12  		time.Sleep(10 * time.Millisecond)
    13  
    14  		value = 2
    15  	}()
    16  
    17  	Sleep(&value, 0, -1)
    18  
    19  	if value != 2 {
    20  		t.Fatalf("bad value: %d", value)
    21  	}
    22  }