Class: Celluloid::Group::Spawner
Instance Attribute Summary collapse
#group
Instance Method Summary
collapse
#active?, #assert_active, #assert_inactive, #create, #each, #each_actor, #forked?, #purge, #to_a
Constructor Details
Returns a new instance of Spawner.
6
7
8
|
# File 'lib/celluloid/group/spawner.rb', line 6
def initialize
super
end
|
Instance Attribute Details
#finalizer ⇒ Object
Returns the value of attribute finalizer.
4
5
6
|
# File 'lib/celluloid/group/spawner.rb', line 4
def finalizer
@finalizer
end
|
Instance Method Details
#busy? ⇒ Boolean
38
39
40
|
# File 'lib/celluloid/group/spawner.rb', line 38
def busy?
to_a.select { |t| t[:celluloid_thread_state] == :running }.any?
end
|
#get(&block) ⇒ Object
10
11
12
13
14
|
# File 'lib/celluloid/group/spawner.rb', line 10
def get(&block)
assert_active
raise ArgumentError, "No block sent to Spawner.get()" unless block_given?
instantiate block
end
|
#idle? ⇒ Boolean
34
35
36
|
# File 'lib/celluloid/group/spawner.rb', line 34
def idle?
to_a.select { |t| t[:celluloid_thread_state] == :running }.empty?
end
|
#shutdown ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/celluloid/group/spawner.rb', line 16
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
|