Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 27 for afterFunc (0.14 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/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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. src/crypto/rand/rand_plan9.go

    type reader struct {
    	mu      sync.Mutex
    	seeded  sync.Once
    	seedErr error
    	key     [32]byte
    }
    
    func (r *reader) Read(b []byte) (n int, err error) {
    	r.seeded.Do(func() {
    		t := time.AfterFunc(time.Minute, func() {
    			println("crypto/rand: blocked for 60 seconds waiting to read random data from the kernel")
    		})
    		defer t.Stop()
    		entropy, err := os.Open(randomDevice)
    		if err != nil {
    			r.seedErr = err
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 13 18:57:38 UTC 2024
    - 1.8K bytes
    - Viewed (0)
  8. src/internal/poll/fd_plan9.go

    		}
    		fd.wtimedout = false
    	}
    	if !t.IsZero() && d > 0 {
    		// Interrupt I/O operation once timer has expired
    		if mode == 'r' || mode == 'r'+'w' {
    			var timer *time.Timer
    			timer = time.AfterFunc(d, func() {
    				fd.rmu.Lock()
    				defer fd.rmu.Unlock()
    				if fd.rtimer != timer {
    					// deadline was changed
    					return
    				}
    				fd.rtimedout = true
    				if fd.raio != nil {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 06 14:00:54 UTC 2024
    - 5.4K bytes
    - Viewed (0)
  9. pkg/ctrlz/home.go

    			fw.RenderHTML(w, errorTmpl, nil)
    		}
    	})
    
    	_ = router.NewRoute().Methods("PUT").Path("/homej/exit").HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
    		w.WriteHeader(http.StatusAccepted)
    		time.AfterFunc(1*time.Second, func() {
    			os.Exit(0)
    		})
    	})
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Wed May 24 14:06:41 UTC 2023
    - 2.5K bytes
    - Viewed (0)
  10. src/crypto/rand/rand_unix.go

    func (r *reader) Read(b []byte) (n int, err error) {
    	boring.Unreachable()
    	if r.used.CompareAndSwap(0, 1) {
    		// First use of randomness. Start timer to warn about
    		// being blocked on entropy not being available.
    		t := time.AfterFunc(time.Minute, warnBlocked)
    		defer t.Stop()
    	}
    	if altGetRandom != nil && altGetRandom(b) == nil {
    		return len(b), nil
    	}
    	if r.used.Load() != 2 {
    		r.mu.Lock()
    		if r.used.Load() != 2 {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sat Oct 01 08:32:46 UTC 2022
    - 1.8K bytes
    - Viewed (0)
Back to top