diff options
author | Keith Rarick <kr@xph.us> | 2010-12-07 18:06:31 -0500 |
---|---|---|
committer | Keith Rarick <kr@xph.us> | 2010-12-07 18:06:31 -0500 |
commit | 12807c6d23653d879910986bac9a58d33cb24478 (patch) | |
tree | 762b73f94c8951dd2a032b71935263d43d4dd37d /src/pkg/runtime | |
parent | 196467cf446bef66960afe5d907c9cef9712615a (diff) | |
download | go-12807c6d23653d879910986bac9a58d33cb24478.tar.gz |
runtime: add Goroutines
R=rsc
CC=golang-dev
http://codereview.appspot.com/3508041
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r-- | src/pkg/runtime/debug.go | 3 | ||||
-rw-r--r-- | src/pkg/runtime/proc.c | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/pkg/runtime/debug.go b/src/pkg/runtime/debug.go index b5f6571fa..3cc5472f6 100644 --- a/src/pkg/runtime/debug.go +++ b/src/pkg/runtime/debug.go @@ -26,6 +26,9 @@ func GOMAXPROCS(n int) int // Cgocalls returns the number of cgo calls made by the current process. func Cgocalls() int64 +// Goroutines returns the number of goroutines that currently exist. +func Goroutines() int32 + type MemStatsType struct { // General statistics. // Not locked during update; approximate. diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index 31641ba98..ff8673a31 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -1192,3 +1192,10 @@ runtime·mid(uint32 ret) ret = m->id; FLUSH(&ret); } + +void +runtime·Goroutines(int32 ret) +{ + ret = runtime·sched.gcount; + FLUSH(&ret); +} |