mirror of
https://github.com/mistergibson/gxg-web-client.git
synced 2026-08-15 03:26:00 -07:00
39 lines
590 B
Ruby
39 lines
590 B
Ruby
class ThreadGroup
|
|
def initialize
|
|
@threads = []
|
|
@enclosed = false
|
|
end
|
|
|
|
private :initialize
|
|
|
|
Default = ThreadGroup.new
|
|
|
|
def add(thread)
|
|
if g = thread.group
|
|
raise ThreadError, "can't move from the enclosed thread group" if g.enclosed?
|
|
|
|
gm = Rubinius::Mirror.reflect g
|
|
gm.remove thread
|
|
end
|
|
|
|
tm = Rubinius::Mirror.reflect thread
|
|
tm.group = self
|
|
|
|
Rubinius.synchronize(@threads) { @threads << thread }
|
|
|
|
self
|
|
end
|
|
|
|
def list
|
|
@threads
|
|
end
|
|
|
|
def enclose
|
|
@enclosed = true
|
|
self
|
|
end
|
|
|
|
def enclosed?
|
|
@enclosed
|
|
end
|
|
end
|