lib/celluloid/group.rb in celluloid-0.17.3 vs lib/celluloid/group.rb in celluloid-0.17.4
- old
+ new
@@ -1,10 +1,11 @@
module Celluloid
class Group
attr_accessor :group
def initialize
+ @pid = $$
@mutex = Mutex.new
@group = []
@running = true
end
@@ -23,10 +24,15 @@
def each
to_a.each { |thread| yield thread }
end
+ def forked?
+ @pid != $$
+ end
+
def to_a
+ return [] if forked?
res = nil
@mutex.synchronize { res = @group.dup }
res
end