• Russ Cox's avatar
    runtime: add timer support, use for package time · 3b860269
    Russ Cox authored
    This looks like it is just moving some code from
    time to runtime (and translating it to C), but the
    runtime can do a better job managing the goroutines,
    and it needs this functionality for its own maintenance
    (for example, for the garbage collector to hand back
    unused memory to the OS on a time delay).
    Might as well have just one copy of the timer logic,
    and runtime can't depend on time, so vice versa.
    
    It also unifies Sleep, NewTicker, and NewTimer behind
    one mechanism, so that there are no claims that one
    is more efficient than another.  (For example, today
    people recommend using time.After instead of time.Sleep
    to avoid blocking an OS thread.)
    
    Fixes #1644.
    Fixes #1731.
    Fixes #2190.
    
    R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
    CC=golang-dev
    https://golang.org/cl/5334051
    3b860269
sys.go 593 Bytes