Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 85 for newTimer (0.12 sec)

  1. src/time/sleep_test.go

    	"math/rand"
    	"runtime"
    	"strings"
    	"sync"
    	"sync/atomic"
    	"testing"
    	. "time"
    	_ "unsafe" // for go:linkname
    )
    
    // newTimerFunc simulates NewTimer using AfterFunc,
    // but this version will not hit the special cases for channels
    // that are used when calling NewTimer.
    // This makes it easy to test both paths.
    func newTimerFunc(d Duration) *Timer {
    	c := make(chan Time, 1)
    	t := AfterFunc(d, func() { c <- Now() })
    	t.C = c
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Mar 22 16:33:57 UTC 2024
    - 22.5K bytes
    - Viewed (0)
  2. staging/src/k8s.io/apiserver/pkg/storage/cacher/cache_watcher_test.go

    		t.Fatal("failed adding an even to the watcher")
    	}
    	if !w.add(&watchCacheEvent{Object: makePod(15), ResourceVersion: 15}, time.NewTimer(1*time.Second)) {
    		t.Fatal("failed adding an even to the watcher")
    	}
    	if w.add(&watchCacheEvent{Object: makePod(20), ResourceVersion: 20}, time.NewTimer(1*time.Second)) {
    		t.Fatal("expected the add method to fail")
    	}
    	if err := wait.PollImmediate(1*time.Second, 5*time.Second, func() (bool, error) {
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Tue Jun 04 09:20:10 UTC 2024
    - 22.9K bytes
    - Viewed (0)
  3. staging/src/k8s.io/apimachinery/pkg/util/wait/backoff.go

    // Timer returns a timer implementation appropriate to this backoff's parameters
    // for use with wait functions.
    func (b Backoff) Timer() Timer {
    	if b.Steps > 1 || b.Jitter != 0 {
    		return &variableTimer{new: internalClock.NewTimer, fn: b.DelayFunc()}
    	}
    	if b.Duration > 0 {
    		return &fixedTimer{new: internalClock.NewTicker, interval: b.Duration}
    	}
    	return newNoopTimer()
    }
    
    // delay implements the core delay algorithm used in this package.
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Tue Mar 14 19:14:11 UTC 2023
    - 16.5K bytes
    - Viewed (0)
  4. src/time/tick_test.go

    			}
    		})
    	}
    
    	run(t, "After", func() { After(Hour) })
    	run(t, "Tick", func() { Tick(Hour) })
    	run(t, "NewTimer", func() { NewTimer(Hour) })
    	run(t, "NewTicker", func() { NewTicker(Hour) })
    	run(t, "NewTimerStop", func() { NewTimer(Hour).Stop() })
    	run(t, "NewTickerStop", func() { NewTicker(Hour).Stop() })
    }
    
    func TestChan(t *testing.T) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jun 11 17:10:37 UTC 2024
    - 14.7K bytes
    - Viewed (0)
  5. internal/dsync/dsync_test.go

    	if !dm.GetLock(ctx, cancel, id, source, Options{Timeout: 5 * time.Minute}) {
    		t.Fatal("GetLock() should be successful")
    	}
    
    	// Make it run twice.
    	timer := time.NewTimer(testDrwMutexRefreshInterval * 2)
    
    	select {
    	case <-ctx.Done():
    		t.Fatal("Lock context canceled which is not expected")
    	case <-timer.C:
    	}
    
    	// Should be safe operation in all cases
    Registered: Sun Jun 16 00:44:34 UTC 2024
    - Last Modified: Sat Dec 24 03:49:07 UTC 2022
    - 11K bytes
    - Viewed (0)
  6. src/os/timeout_test.go

    func TestReadTimeoutMustNotReturn(t *testing.T) {
    	t.Parallel()
    
    	r, w, err := os.Pipe()
    	if err != nil {
    		t.Fatal(err)
    	}
    	defer r.Close()
    	defer w.Close()
    
    	max := time.NewTimer(100 * time.Millisecond)
    	defer max.Stop()
    	ch := make(chan error)
    	go func() {
    		if err := r.SetDeadline(time.Now().Add(-5 * time.Second)); err != nil {
    			t.Error(err)
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Jun 14 00:03:57 UTC 2023
    - 17.1K bytes
    - Viewed (0)
  7. staging/src/k8s.io/apiserver/pkg/server/filters/goaway_test.go

    				t.Fatalf("expect TCP connection: %d, actual: %d", tc.expectConnections, len(localAddr))
    			}
    
    			// check if watch request is broken by GOAWAY frame
    			watchTimeout := time.NewTimer(time.Second * 10)
    			defer watchTimeout.Stop()
    			for _, watchCh := range watchChs {
    				select {
    				case watchResp := <-watchCh:
    					if watchResp.err != nil {
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed Nov 17 12:58:54 UTC 2021
    - 13.9K bytes
    - Viewed (0)
  8. staging/src/k8s.io/apimachinery/pkg/util/wait/loop_test.go

    	testingclock "k8s.io/utils/clock/testing"
    )
    
    func timerWithClock(t Timer, c clock.WithTicker) Timer {
    	switch t := t.(type) {
    	case *fixedTimer:
    		t.new = c.NewTicker
    	case *variableTimer:
    		t.new = c.NewTimer
    	default:
    		panic("unrecognized timer type, cannot inject clock")
    	}
    	return t
    }
    
    func Test_loopConditionWithContextImmediateDelay(t *testing.T) {
    	fakeClock := testingclock.NewFakeClock(time.Time{})
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Thu Oct 19 02:48:08 UTC 2023
    - 15.8K bytes
    - Viewed (0)
  9. src/context/x_test.go

    			t.Errorf("c[%d].Err() == %v want %v", i, e, Canceled)
    		}
    	}
    }
    
    func testDeadline(c Context, name string, t *testing.T) {
    	t.Helper()
    	d := quiescent(t)
    	timer := time.NewTimer(d)
    	defer timer.Stop()
    	select {
    	case <-timer.C:
    		t.Fatalf("%s: context not timed out after %v", name, d)
    	case <-c.Done():
    	}
    	if e := c.Err(); e != DeadlineExceeded {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 26 19:58:28 UTC 2024
    - 26.3K bytes
    - Viewed (0)
  10. cmd/bucket-targets.go

    	}
    	clnt.SetCustomTransport(globalRemoteTargetTransport)
    	return clnt
    }
    
    // heartBeat performs liveness check on remote endpoints.
    func (sys *BucketTargetSys) heartBeat(ctx context.Context) {
    	hcTimer := time.NewTimer(defaultHealthCheckDuration)
    	defer hcTimer.Stop()
    	for {
    		select {
    		case <-hcTimer.C:
    			sys.hMutex.RLock()
    			eps := make([]madmin.ServerProperties, 0, len(sys.hc))
    			for _, ep := range sys.hc {
    Registered: Sun Jun 16 00:44:34 UTC 2024
    - Last Modified: Wed May 01 01:09:56 UTC 2024
    - 20.9K bytes
    - Viewed (0)
Back to top