github.com/sitano/gsysint@v0.0.0-20190607084937-69a4f3233e4e/g/time.go (about)

     1  // 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  // Time-related runtime and pieces of package time.
     6  
     7  package g
     8  
     9  // Package time knows the layout of this structure.
    10  // If this struct changes, adjust ../time/sleep.go:/runtimeTimer.
    11  // For GOOS=nacl, package syscall knows the layout of this structure.
    12  // If this struct changes, adjust ../syscall/net_nacl.go:/runtimeTimer.
    13  type Timer struct {
    14  	TB *TimersBucket // the bucket the timer lives in
    15  	I  int           // heap index
    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  	When   int64
    21  	Period int64
    22  	F      func(interface{}, uintptr)
    23  	Arg    interface{}
    24  	Seq    uintptr
    25  }
    26  
    27  //go:notinheap
    28  type TimersBucket struct {
    29  	lock         Mutex
    30  	gp           *G
    31  	created      bool
    32  	sleeping     bool
    33  	rescheduling bool
    34  	sleepUntil   int64
    35  	waitnote     Note
    36  	t            []*Timer
    37  }
    38