-
-
Save fd/7136de67a56e174d8c06cb505f7278aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func NumActiveGoroutine() int { | |
num := 0 | |
lock(&sched.lock) | |
lock(&allglock) | |
for gi := 0; gi < len(allgs); gi++ { | |
gp := allgs[gi] | |
if isSystemGoroutine(gp) { | |
continue | |
} | |
s := readgstatus(gp) | |
if s&(_Grunnable|_Grunning|_Gsyscall) > 0 { | |
num++ | |
} | |
} | |
unlock(&allglock) | |
unlock(&sched.lock) | |
return num | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment