Class: Celluloid::Group::Spawner
Instance Attribute Summary collapse
#group
Instance Method Summary
collapse
#active?, #assert_active, #assert_inactive, #create, #each, #each_actor, #purge, #to_a
Constructor Details
Returns a new instance of Spawner.
8
9
10
|
# File 'lib/celluloid/group/spawner.rb', line 8
def initialize
super
end
|
Instance Attribute Details
#finalizer ⇒ Object
Returns the value of attribute finalizer.
6
7
8
|
# File 'lib/celluloid/group/spawner.rb', line 6
def finalizer
@finalizer
end
|
Instance Method Details
#busy? ⇒ Boolean
40
41
42
|
# File 'lib/celluloid/group/spawner.rb', line 40
def busy?
to_a.select { |t| t[:celluloid_thread_state] == :running }.any?
end
|
#get(&block) ⇒ Object
12
13
14
15
16
|
# File 'lib/celluloid/group/spawner.rb', line 12
def get(&block)
assert_active
fail ArgumentError.new("No block sent to Spawner.get()") unless block_given?
instantiate block
end
|
#idle? ⇒ Boolean
36
37
38
|
# File 'lib/celluloid/group/spawner.rb', line 36
def idle?
to_a.select { |t| t[:celluloid_thread_state] == :running }.empty?
end
|
#shutdown ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/celluloid/group/spawner.rb', line 18
def shutdown
@running = false
queue = []
@mutex.synchronize do
loop do
break if @group.empty?
th = @group.shift
th.kill
queue << th
end
end
Thread.pass unless queue.empty?
loop do
break if queue.empty?
queue.pop.join
end
end
|