]> Cypherpunks repositories - gostls13.git/commit
runtime: add timer support, use for package time
authorRuss Cox <rsc@golang.org>
Wed, 9 Nov 2011 20:17:05 +0000 (15:17 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 9 Nov 2011 20:17:05 +0000 (15:17 -0500)
commit3b860269eeb0b2d6176da5c972139b7c21d5251b
tree247969f3d82d13d31928f470ec4c4cd6a7616847
parentfbfed49134bca038184dbc1a427e82647fc1f12e
runtime: add timer support, use for package time

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
15 files changed:
src/pkg/runtime/darwin/os.h
src/pkg/runtime/darwin/thread.c
src/pkg/runtime/freebsd/thread.c
src/pkg/runtime/linux/thread.c
src/pkg/runtime/lock_futex.c
src/pkg/runtime/lock_sema.c
src/pkg/runtime/openbsd/thread.c
src/pkg/runtime/plan9/thread.c
src/pkg/runtime/proc.c
src/pkg/runtime/runtime.h
src/pkg/runtime/time.goc
src/pkg/runtime/windows/thread.c
src/pkg/time/sleep.go
src/pkg/time/sys.go
src/pkg/time/tick.go