]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add Goroutines
authorKeith Rarick <kr@xph.us>
Tue, 7 Dec 2010 23:06:31 +0000 (18:06 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 7 Dec 2010 23:06:31 +0000 (18:06 -0500)
R=rsc
CC=golang-dev
https://golang.org/cl/3508041

src/pkg/runtime/debug.go
src/pkg/runtime/proc.c

index b5f6571faa886bb004593f4da16f88a78aff1aa6..3cc5472f6b02345a96080700cefec16f942b4e47 100644 (file)
@@ -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.
index 31641ba982bbbd3e33771333a44440c4b6ce3c3c..ff8673a314d7f1a396734987b426e9cf35fb63f0 100644 (file)
@@ -1192,3 +1192,10 @@ runtime·mid(uint32 ret)
        ret = m->id;
        FLUSH(&ret);
 }
+
+void
+runtime·Goroutines(int32 ret)
+{
+       ret = runtime·sched.gcount;
+       FLUSH(&ret);
+}