github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/runtime/timer.go (about)

     1  // Portions copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package runtime
     6  
     7  type puintptr uintptr
     8  
     9  // Package time knows the layout of this structure.
    10  // If this struct changes, adjust ../time/sleep.go:/runtimeTimer.
    11  type timer struct {
    12  	// If this timer is on a heap, which P's heap it is on.
    13  	// puintptr rather than *p to match uintptr in the versions
    14  	// of this struct defined in other packages.
    15  	pp puintptr
    16  
    17  	// Timer wakes up at when, and then at when+period, ... (period > 0 only)
    18  	// each time calling f(arg, now) in the timer goroutine, so f must be
    19  	// a well-behaved function and not block.
    20  	//
    21  	// when must be positive on an active timer.
    22  	when   int64
    23  	period int64
    24  	f      func(any, uintptr)
    25  	arg    any
    26  	seq    uintptr
    27  
    28  	// What to set the when field to in timerModifiedXX status.
    29  	nextwhen int64
    30  
    31  	// The status field holds one of the values below.
    32  	status uint32
    33  }