Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for TestMutex (0.09 sec)

  1. src/sync/mutex_test.go

    	for i := 0; i < loops; i++ {
    		if i%3 == 0 {
    			if m.TryLock() {
    				m.Unlock()
    			}
    			continue
    		}
    		m.Lock()
    		m.Unlock()
    	}
    	cdone <- true
    }
    
    func TestMutex(t *testing.T) {
    	if n := runtime.SetMutexProfileFraction(1); n != 0 {
    		t.Logf("got mutexrate %d expected 0", n)
    	}
    	defer runtime.SetMutexProfileFraction(0)
    
    	m := new(Mutex)
    
    	m.Lock()
    	if m.TryLock() {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jun 16 21:25:35 UTC 2022
    - 5.9K bytes
    - Viewed (0)
  2. internal/dsync/dsync_test.go

    func HammerMutex(m *DRWMutex, loops int, cdone chan bool) {
    	for i := 0; i < loops; i++ {
    		m.Lock(id, source)
    		m.Unlock(context.Background())
    	}
    	cdone <- true
    }
    
    // Borrowed from mutex_test.go
    func TestMutex(t *testing.T) {
    	loops := 200
    	if testing.Short() {
    		loops = 5
    	}
    	c := make(chan bool)
    	m := NewDRWMutex(ds, "test")
    	for i := 0; i < 10; i++ {
    		go HammerMutex(m, loops, c)
    	}
    Registered: Sun Jun 16 00:44:34 UTC 2024
    - Last Modified: Sat Dec 24 03:49:07 UTC 2022
    - 11K bytes
    - Viewed (0)
Back to top