Skip to content

Modern Chan GoroutineCount

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Goroutines and Channels › Goroutines and Channels › GoroutineCount

GoroutineCount

Returns how many goroutines exist right now, as a snapshot for diagnostics.

Syntax

GoroutineCount( ) as int32

Notes

  • A diagnostic, and a snapshot: it is stale the moment it returns.
  • Useful for asserting in a test that a fan-out actually finished, and for spotting a leak where goroutines accumulate.
  • Not a scheduling control -- there is no way to cap it from here.

Examples

#import "std/tasks"
using tasks

print GoroutineCount( ) >= 0     '' -1 (true)

'' Worth asserting at the end of a test: a count that keeps climbing
'' between runs is a goroutine leak
dim as int32 before = GoroutineCount( )
print before >= 0                '' -1 (true)

Library: Goroutines and Channels
Category: Goroutines and Channels
Documented under: Members

Clone this wiki locally