github.com/goplusjs/gopherjs@v1.2.6-0.20211206034512-f187917453b8/compiler/natives/src/time/go115_timer.go (about)

     1  // +build js
     2  // +build go1.15
     3  
     4  package time
     5  
     6  import "github.com/gopherjs/gopherjs/js"
     7  
     8  type runtimeTimer struct {
     9  	i       int32
    10  	when    int64
    11  	period  int64
    12  	f       func(interface{}, uintptr)
    13  	arg     interface{}
    14  	timeout *js.Object
    15  	active  bool
    16  	seq     uintptr
    17  }
    18  
    19  func (t *Ticker) Reset(d Duration) {
    20  	if t.r.f == nil {
    21  		panic("time: Reset called on uninitialized Ticker")
    22  	}
    23  	stopTimer(&t.r)
    24  	c := make(chan Time, 1)
    25  	t.C = c
    26  	t.r = runtimeTimer{
    27  		when:   when(d),
    28  		period: int64(d),
    29  		f:      sendTime,
    30  		arg:    c,
    31  	}
    32  	startTimer(&t.r)
    33  }