Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

Ractor.count

count

Returns the number of Ractors currently running or blocking (waiting).

Example
Ractor.count                   #=> 1
r = Ractor.new(name: 'example') { Ractor.yield(1) }
Ractor.count                   #=> 2 (main + example ractor)
r.take                         # wait for Ractor.yield(1)
r.take                         # wait until r will finish
Ractor.count                   #=> 1
See also .current .main also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0