Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 66 for afterFunc (0.21 sec)

  1. src/context/afterfunc_test.go

    	return nil
    }
    
    func (c *afterFuncContext) AfterFunc(f func()) func() bool {
    	c.mu.Lock()
    	defer c.mu.Unlock()
    	k := new(byte)
    	if c.afterFuncs == nil {
    		c.afterFuncs = make(map[*byte]func())
    	}
    	c.afterFuncs[k] = f
    	return func() bool {
    		c.mu.Lock()
    		defer c.mu.Unlock()
    		_, ok := c.afterFuncs[k]
    		delete(c.afterFuncs, k)
    		return ok
    	}
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Sep 18 16:58:52 UTC 2023
    - 3.4K bytes
    - Viewed (0)
  2. src/runtime/race/testdata/sync_test.go

    	i := 2
    	c := make(chan bool)
    	var f func()
    	f = func() {
    		i--
    		if i >= 0 {
    			time.AfterFunc(0, f)
    		} else {
    			c <- true
    		}
    	}
    
    	time.AfterFunc(0, f)
    	<-c
    }
    
    func TestNoRaceAfterFunc2(t *testing.T) {
    	var x int
    	_ = x
    	timer := time.AfterFunc(10, func() {
    		x = 1
    	})
    	defer timer.Stop()
    }
    
    func TestNoRaceAfterFunc3(t *testing.T) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Nov 10 15:05:17 UTC 2020
    - 3K bytes
    - Viewed (0)
  3. src/context/example_test.go

    	// Output:
    	// found value: Go
    	// key not found: color
    }
    
    // This example uses AfterFunc to define a function which waits on a sync.Cond,
    // stopping the wait when a context is canceled.
    func ExampleAfterFunc_cond() {
    	waitOnCond := func(ctx context.Context, cond *sync.Cond, conditionMet func() bool) error {
    		stopf := context.AfterFunc(ctx, func() {
    			// We need to acquire cond.L here to be sure that the Broadcast
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Aug 21 20:24:28 UTC 2023
    - 6.7K bytes
    - Viewed (0)
  4. src/time/sleep_test.go

    // behavior is tested elsewhere, since After and AfterFunc share
    // the same code.
    func TestAfterFunc(t *testing.T) {
    	i := 10
    	c := make(chan bool)
    	var f func()
    	f = func() {
    		i--
    		if i >= 0 {
    			AfterFunc(0, f)
    			Sleep(1 * Second)
    		} else {
    			c <- true
    		}
    	}
    
    	AfterFunc(0, f)
    	<-c
    }
    
    func TestTickerStress(t *testing.T) {
    	var stop atomic.Bool
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Mar 22 16:33:57 UTC 2024
    - 22.5K bytes
    - Viewed (0)
  5. src/context/x_test.go

    	donec := make(chan struct{})
    	stop := AfterFunc(ctx, func() {
    		close(donec)
    	})
    	select {
    	case <-donec:
    		t.Fatalf("AfterFunc called before context is done")
    	case <-time.After(shortDuration):
    	}
    	cancel()
    	select {
    	case <-donec:
    	case <-time.After(veryLongDuration):
    		t.Fatalf("AfterFunc not called after context is canceled")
    	}
    	if stop() {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 26 19:58:28 UTC 2024
    - 26.3K bytes
    - Viewed (0)
  6. src/runtime/race/testdata/time_test.go

    	v := 0
    	_ = v
    	c := make(chan int)
    	f := func() {
    		v = 1
    		c <- 0
    	}
    	v = 2
    	time.AfterFunc(1, f)
    	<-c
    	v = 3
    }
    
    func TestNoRaceAfterFuncReset(_ *testing.T) {
    	v := 0
    	_ = v
    	c := make(chan int)
    	f := func() {
    		v = 1
    		c <- 0
    	}
    	t := time.AfterFunc(time.Hour, f)
    	t.Stop()
    	v = 2
    	t.Reset(1)
    	<-c
    	v = 3
    }
    
    func TestNoRaceTimer(_ *testing.T) {
    	v := 0
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Mar 08 22:34:15 UTC 2024
    - 1.3K bytes
    - Viewed (0)
  7. pkg/scheduler/framework/runtime/waiting_pods_map.go

    	// The time.AfterFunc calls wp.Reject which iterates through pendingPlugins map. Acquire the
    	// lock here so that time.AfterFunc can only execute after newWaitingPod finishes.
    	wp.mu.Lock()
    	defer wp.mu.Unlock()
    	for k, v := range pluginsMaxWaitTime {
    		plugin, waitTime := k, v
    		wp.pendingPlugins[plugin] = time.AfterFunc(waitTime, func() {
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Fri May 17 09:07:27 UTC 2024
    - 4.5K bytes
    - Viewed (0)
  8. src/context/context_test.go

    	cancel()
    	checkChildren("after canceling WithTimeout child", ctx, 0)
    
    	ctx, _ = WithCancel(Background())
    	checkChildren("after creation", ctx, 0)
    	stop := AfterFunc(ctx, func() {})
    	checkChildren("with AfterFunc child ", ctx, 1)
    	stop()
    	checkChildren("after stopping AfterFunc child ", ctx, 0)
    }
    
    type myCtx struct {
    	Context
    }
    
    type myDoneCtx struct {
    	Context
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Apr 19 19:13:01 UTC 2023
    - 7.7K bytes
    - Viewed (0)
  9. src/time/sleep.go

    // unless the Timer was created by [AfterFunc].
    // A Timer must be created with [NewTimer] or AfterFunc.
    type Timer struct {
    	C         <-chan Time
    	initTimer bool
    }
    
    // Stop prevents the [Timer] from firing.
    // It returns true if the call stops the timer, false if the timer has already
    // expired or been stopped.
    //
    // For a func-based timer created with [AfterFunc](d, f),
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Apr 04 14:21:30 UTC 2024
    - 8.5K bytes
    - Viewed (0)
  10. src/context/context.go

    	// it might still have an error even though it won't have a cause.
    	return c.Err()
    }
    
    // AfterFunc arranges to call f in its own goroutine after ctx is done
    // (canceled or timed out).
    // If ctx is already done, AfterFunc calls f immediately in its own goroutine.
    //
    // Multiple calls to AfterFunc on a context operate independently;
    // one does not replace another.
    //
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 26 19:58:28 UTC 2024
    - 23.7K bytes
    - Viewed (0)
Back to top