Temporary tag for this failure. Updated CI spec coming.
[rbx.git] / kernel / core / thread_group.rb
blob8a22f2b0935f423e685c6c79e844f020093340cb
1 # depends on: class.rb
3 class ThreadGroup
4   def initialize
5     @threads = []
6   end
7   
8   def add(thread)
9     if thread.group
10       thread.group.remove(thread)
11     end
12     thread.add_to_group self
13     @threads << WeakRef.new(thread)
14     self
15   end
17   def prune
18     @threads.delete_if { |w| !w.weakref_alive? or !w.object.alive? }
19   end
21   private :prune
22   
23   def remove(thread)
24     prune
25     @threads.delete_if { |w| w.object == thread }
26   end
27   
28   def list
29     prune
30     @threads.map { |w| w.object }
31   end
33   def list_all
34     @threads.delete_if { |w| !w.weakref_alive? }
35     @threads.map { |w| w.object }
36   end
38 end