celluloid 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of celluloid might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +333 -0
- data/README.md +1 -1
- data/culture/CODE_OF_CONDUCT.md +28 -0
- data/culture/Gemfile +9 -0
- data/culture/README.md +22 -0
- data/culture/Rakefile +5 -0
- data/culture/SYNC.md +70 -0
- data/culture/celluloid-culture.gemspec +18 -0
- data/culture/gems/README.md +39 -0
- data/culture/gems/dependencies.yml +78 -0
- data/culture/gems/loader.rb +101 -0
- data/culture/rubocop/README.md +38 -0
- data/culture/rubocop/lint.yml +8 -0
- data/culture/rubocop/metrics.yml +15 -0
- data/culture/rubocop/rubocop.yml +4 -0
- data/culture/rubocop/style.yml +48 -0
- data/culture/spec/gems_spec.rb +2 -0
- data/culture/spec/spec_helper.rb +0 -0
- data/culture/spec/sync_spec.rb +2 -0
- data/culture/sync.rb +56 -0
- data/culture/tasks/rspec.rake +5 -0
- data/culture/tasks/rubocop.rake +2 -0
- data/examples/basic_usage.rb +49 -0
- data/examples/futures.rb +38 -0
- data/examples/ring.rb +61 -0
- data/examples/simple_pmap.rb +14 -0
- data/examples/timers.rb +72 -0
- data/lib/celluloid.rb +142 -127
- data/lib/celluloid/actor.rb +47 -41
- data/lib/celluloid/actor_system.rb +75 -22
- data/lib/celluloid/autostart.rb +1 -1
- data/lib/celluloid/backported.rb +2 -0
- data/lib/celluloid/call/async.rb +16 -0
- data/lib/celluloid/call/block.rb +22 -0
- data/lib/celluloid/call/sync.rb +70 -0
- data/lib/celluloid/calls.rb +25 -114
- data/lib/celluloid/cell.rb +32 -20
- data/lib/celluloid/condition.rb +3 -3
- data/lib/celluloid/core_ext.rb +1 -1
- data/lib/celluloid/current.rb +2 -0
- data/lib/celluloid/deprecate.rb +18 -0
- data/lib/celluloid/exceptions.rb +1 -1
- data/lib/celluloid/fiber.rb +3 -3
- data/lib/celluloid/future.rb +7 -6
- data/lib/celluloid/group.rb +65 -0
- data/lib/celluloid/group/manager.rb +27 -0
- data/lib/celluloid/group/pool.rb +125 -0
- data/lib/celluloid/group/spawner.rb +71 -0
- data/lib/celluloid/logging.rb +5 -5
- data/lib/celluloid/mailbox.rb +14 -13
- data/lib/celluloid/mailbox/evented.rb +76 -0
- data/lib/celluloid/notices.rb +15 -0
- data/lib/celluloid/proxies.rb +12 -0
- data/lib/celluloid/proxy/abstract.rb +24 -0
- data/lib/celluloid/proxy/actor.rb +46 -0
- data/lib/celluloid/proxy/async.rb +36 -0
- data/lib/celluloid/proxy/block.rb +31 -0
- data/lib/celluloid/proxy/cell.rb +76 -0
- data/lib/celluloid/proxy/future.rb +40 -0
- data/lib/celluloid/proxy/sync.rb +44 -0
- data/lib/celluloid/rspec.rb +9 -10
- data/lib/celluloid/system_events.rb +16 -15
- data/lib/celluloid/{tasks.rb → task.rb} +21 -21
- data/lib/celluloid/task/fibered.rb +45 -0
- data/lib/celluloid/task/threaded.rb +59 -0
- data/lib/celluloid/test.rb +1 -1
- data/lib/celluloid/thread.rb +6 -1
- data/lib/celluloid/version.rb +3 -0
- data/spec/celluloid/actor_spec.rb +2 -2
- data/spec/celluloid/actor_system_spec.rb +35 -21
- data/spec/celluloid/block_spec.rb +3 -5
- data/spec/celluloid/calls_spec.rb +33 -11
- data/spec/celluloid/condition_spec.rb +16 -13
- data/spec/celluloid/evented_mailbox_spec.rb +1 -31
- data/spec/celluloid/future_spec.rb +13 -10
- data/spec/celluloid/group/elastic_spec.rb +0 -0
- data/spec/celluloid/group/manager_spec.rb +0 -0
- data/spec/celluloid/group/pool_spec.rb +8 -0
- data/spec/celluloid/group/spawner_spec.rb +8 -0
- data/spec/celluloid/mailbox/evented_spec.rb +27 -0
- data/spec/celluloid/mailbox_spec.rb +1 -3
- data/spec/celluloid/misc/leak_spec.rb +73 -0
- data/spec/celluloid/task/fibered_spec.rb +5 -0
- data/spec/celluloid/task/threaded_spec.rb +5 -0
- data/spec/celluloid/timer_spec.rb +14 -16
- data/spec/deprecate/actor_system_spec.rb +72 -0
- data/spec/deprecate/block_spec.rb +52 -0
- data/spec/deprecate/calls_spec.rb +57 -0
- data/spec/deprecate/evented_mailbox_spec.rb +34 -0
- data/spec/deprecate/future_spec.rb +32 -0
- data/spec/deprecate/internal_pool_spec.rb +4 -0
- data/spec/shared/actor_examples.rb +1237 -0
- data/spec/shared/group_examples.rb +121 -0
- data/{lib/celluloid/rspec → spec/shared}/mailbox_examples.rb +20 -17
- data/{lib/celluloid/rspec → spec/shared}/task_examples.rb +9 -8
- data/spec/spec_helper.rb +72 -16
- data/spec/support/coverage.rb +4 -0
- data/spec/support/crash_checking.rb +68 -0
- data/spec/support/debugging.rb +31 -0
- data/spec/support/env.rb +16 -0
- data/{lib/celluloid/rspec/example_actor_class.rb → spec/support/examples/actor_class.rb} +21 -2
- data/spec/support/examples/evented_mailbox_class.rb +27 -0
- data/spec/support/includer.rb +9 -0
- data/spec/support/logging.rb +63 -0
- data/spec/support/loose_threads.rb +65 -0
- data/spec/support/reset_class_variables.rb +27 -0
- data/spec/support/sleep_and_wait.rb +14 -0
- data/spec/support/split_logs.rb +1 -0
- data/spec/support/stubbing.rb +14 -0
- metadata +255 -95
- data/lib/celluloid/call_chain.rb +0 -13
- data/lib/celluloid/cpu_counter.rb +0 -34
- data/lib/celluloid/evented_mailbox.rb +0 -73
- data/lib/celluloid/fsm.rb +0 -186
- data/lib/celluloid/handlers.rb +0 -41
- data/lib/celluloid/internal_pool.rb +0 -159
- data/lib/celluloid/legacy.rb +0 -9
- data/lib/celluloid/links.rb +0 -36
- data/lib/celluloid/logger.rb +0 -93
- data/lib/celluloid/logging/incident.rb +0 -21
- data/lib/celluloid/logging/incident_logger.rb +0 -129
- data/lib/celluloid/logging/incident_reporter.rb +0 -48
- data/lib/celluloid/logging/log_event.rb +0 -20
- data/lib/celluloid/logging/ring_buffer.rb +0 -65
- data/lib/celluloid/method.rb +0 -32
- data/lib/celluloid/notifications.rb +0 -83
- data/lib/celluloid/pool_manager.rb +0 -146
- data/lib/celluloid/probe.rb +0 -73
- data/lib/celluloid/properties.rb +0 -24
- data/lib/celluloid/proxies/abstract_proxy.rb +0 -20
- data/lib/celluloid/proxies/actor_proxy.rb +0 -38
- data/lib/celluloid/proxies/async_proxy.rb +0 -31
- data/lib/celluloid/proxies/block_proxy.rb +0 -29
- data/lib/celluloid/proxies/cell_proxy.rb +0 -68
- data/lib/celluloid/proxies/future_proxy.rb +0 -35
- data/lib/celluloid/proxies/sync_proxy.rb +0 -36
- data/lib/celluloid/receivers.rb +0 -63
- data/lib/celluloid/registry.rb +0 -57
- data/lib/celluloid/responses.rb +0 -44
- data/lib/celluloid/rspec/actor_examples.rb +0 -1054
- data/lib/celluloid/signals.rb +0 -23
- data/lib/celluloid/stack_dump.rb +0 -133
- data/lib/celluloid/supervision_group.rb +0 -169
- data/lib/celluloid/supervisor.rb +0 -22
- data/lib/celluloid/task_set.rb +0 -49
- data/lib/celluloid/tasks/task_fiber.rb +0 -43
- data/lib/celluloid/tasks/task_thread.rb +0 -53
- data/lib/celluloid/thread_handle.rb +0 -50
- data/lib/celluloid/uuid.rb +0 -38
- data/spec/celluloid/cpu_counter_spec.rb +0 -82
- data/spec/celluloid/fsm_spec.rb +0 -107
- data/spec/celluloid/internal_pool_spec.rb +0 -52
- data/spec/celluloid/links_spec.rb +0 -45
- data/spec/celluloid/logging/ring_buffer_spec.rb +0 -38
- data/spec/celluloid/notifications_spec.rb +0 -120
- data/spec/celluloid/pool_spec.rb +0 -92
- data/spec/celluloid/probe_spec.rb +0 -121
- data/spec/celluloid/properties_spec.rb +0 -42
- data/spec/celluloid/registry_spec.rb +0 -64
- data/spec/celluloid/stack_dump_spec.rb +0 -64
- data/spec/celluloid/supervision_group_spec.rb +0 -65
- data/spec/celluloid/supervisor_spec.rb +0 -103
- data/spec/celluloid/tasks/task_fiber_spec.rb +0 -5
- data/spec/celluloid/tasks/task_thread_spec.rb +0 -5
- data/spec/celluloid/thread_handle_spec.rb +0 -26
- data/spec/celluloid/uuid_spec.rb +0 -11
data/spec/celluloid/pool_spec.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Celluloid.pool", actor_system: :global do
|
4
|
-
class ExampleError < StandardError; end
|
5
|
-
|
6
|
-
class MyWorker
|
7
|
-
include Celluloid
|
8
|
-
|
9
|
-
def process(queue = nil)
|
10
|
-
if queue
|
11
|
-
queue << :done
|
12
|
-
else
|
13
|
-
:done
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def sleepy_work
|
18
|
-
t = Time.now.to_f
|
19
|
-
sleep 0.25
|
20
|
-
t
|
21
|
-
end
|
22
|
-
|
23
|
-
def crash
|
24
|
-
raise ExampleError, "zomgcrash"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_concurrency_of(pool)
|
29
|
-
baseline = Time.now.to_f
|
30
|
-
values = 10.times.map { pool.future.sleepy_work }.map(&:value)
|
31
|
-
values.select {|t| t - baseline < 0.1 }.length
|
32
|
-
end
|
33
|
-
|
34
|
-
subject { MyWorker.pool }
|
35
|
-
|
36
|
-
it "processes work units synchronously" do
|
37
|
-
subject.process.should be :done
|
38
|
-
end
|
39
|
-
|
40
|
-
it "processes work units asynchronously" do
|
41
|
-
queue = Queue.new
|
42
|
-
subject.async.process(queue)
|
43
|
-
queue.pop.should be :done
|
44
|
-
end
|
45
|
-
|
46
|
-
it "handles crashes" do
|
47
|
-
expect { subject.crash }.to raise_error(ExampleError)
|
48
|
-
subject.process.should be :done
|
49
|
-
end
|
50
|
-
|
51
|
-
it "uses a fixed-sized number of threads" do
|
52
|
-
subject # eagerly evaluate the pool to spawn it
|
53
|
-
|
54
|
-
actors = Celluloid::Actor.all
|
55
|
-
100.times.map { subject.future(:process) }.map(&:value)
|
56
|
-
|
57
|
-
new_actors = Celluloid::Actor.all - actors
|
58
|
-
new_actors.should eq []
|
59
|
-
end
|
60
|
-
|
61
|
-
it "terminates" do
|
62
|
-
expect { subject.terminate }.to_not raise_exception
|
63
|
-
end
|
64
|
-
|
65
|
-
it "handles many requests" do
|
66
|
-
futures = 10.times.map do
|
67
|
-
subject.future.process
|
68
|
-
end
|
69
|
-
futures.map(&:value)
|
70
|
-
end
|
71
|
-
|
72
|
-
context "#size=" do
|
73
|
-
subject { MyWorker.pool size: 4 }
|
74
|
-
|
75
|
-
it "should adjust the pool size up", pending: 'flaky' do
|
76
|
-
expect(test_concurrency_of(subject)).to eq(4)
|
77
|
-
|
78
|
-
subject.size = 6
|
79
|
-
subject.size.should == 6
|
80
|
-
|
81
|
-
test_concurrency_of(subject).should == 6
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should adjust the pool size down" do
|
85
|
-
test_concurrency_of(subject).should == 4
|
86
|
-
|
87
|
-
subject.size = 2
|
88
|
-
subject.size.should == 2
|
89
|
-
test_concurrency_of(subject).should == 2
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class DummyActor; include Celluloid; end
|
4
|
-
|
5
|
-
class TestProbeClient
|
6
|
-
include Celluloid
|
7
|
-
include Celluloid::Notifications
|
8
|
-
|
9
|
-
attr_reader :buffer
|
10
|
-
|
11
|
-
def initialize()
|
12
|
-
@condition = Condition.new
|
13
|
-
subscribe(/celluloid\.events\..+/, :event_received)
|
14
|
-
@buffer = []
|
15
|
-
end
|
16
|
-
|
17
|
-
def wait
|
18
|
-
@condition.wait
|
19
|
-
end
|
20
|
-
|
21
|
-
def wait_event(topic, expected_actor1 = nil, expected_actor2 = nil)
|
22
|
-
loop do
|
23
|
-
wait
|
24
|
-
while ev = @buffer.shift()
|
25
|
-
if (ev[0] == topic) && (ev[1].mailbox.address == expected_actor1.mailbox.address) &&
|
26
|
-
(expected_actor2.nil? || (ev[2].mailbox.address == expected_actor2.mailbox.address) )
|
27
|
-
return ev
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def event_received(topic, args)
|
34
|
-
@buffer << [topic, args[0], args[1]]
|
35
|
-
@condition.signal
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "Probe", actor_system: :global do
|
40
|
-
describe 'on boot' do
|
41
|
-
it 'should capture system actor spawn' do
|
42
|
-
client = TestProbeClient.new
|
43
|
-
Celluloid::Probe.run
|
44
|
-
create_events = []
|
45
|
-
received_named_events = {
|
46
|
-
:default_incident_reporter => nil,
|
47
|
-
:notifications_fanout => nil
|
48
|
-
}
|
49
|
-
# wait for the events we seek
|
50
|
-
Timeout.timeout(5) do
|
51
|
-
loop do
|
52
|
-
client.wait
|
53
|
-
while ev = client.buffer.shift
|
54
|
-
if ev[0] == 'celluloid.events.actor_created'
|
55
|
-
create_events << ev
|
56
|
-
elsif ev[0] == 'celluloid.events.actor_named'
|
57
|
-
if received_named_events.keys.include?(ev[1].name)
|
58
|
-
received_named_events[ev[1].name] = ev[1].mailbox.address
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
if received_named_events.all?{|_, v| v != nil }
|
63
|
-
break
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
received_named_events.all?{|_, v| v != nil }.should == true
|
68
|
-
# now check we got the create events for every actors
|
69
|
-
received_named_events.each do |_, mailbox_address|
|
70
|
-
found = create_events.detect{|_, aa| aa.mailbox.address == mailbox_address }
|
71
|
-
found.should_not == nil
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe 'after boot' do
|
77
|
-
it 'should send a notification when an actor is spawned' do
|
78
|
-
client = TestProbeClient.new
|
79
|
-
Celluloid::Probe.run
|
80
|
-
a = DummyActor.new
|
81
|
-
event = Timeout.timeout(5) do
|
82
|
-
client.wait_event('celluloid.events.actor_created', a)
|
83
|
-
end
|
84
|
-
event.should_not == nil
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should send a notification when an actor is named' do
|
88
|
-
client = TestProbeClient.new
|
89
|
-
Celluloid::Probe.run
|
90
|
-
a = DummyActor.new
|
91
|
-
Celluloid::Actor['a name'] = a
|
92
|
-
event = Timeout.timeout(5) do
|
93
|
-
client.wait_event('celluloid.events.actor_named', a)
|
94
|
-
end
|
95
|
-
event.should_not == nil
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should send a notification when actor dies' do
|
99
|
-
client = TestProbeClient.new
|
100
|
-
Celluloid::Probe.run
|
101
|
-
a = DummyActor.new
|
102
|
-
a.terminate
|
103
|
-
event = Timeout.timeout(5) do
|
104
|
-
client.wait_event('celluloid.events.actor_died', a)
|
105
|
-
end
|
106
|
-
event.should_not == nil
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'should send a notification when actors are linked' do
|
110
|
-
client = TestProbeClient.new
|
111
|
-
Celluloid::Probe.run
|
112
|
-
a = DummyActor.new
|
113
|
-
b = DummyActor.new
|
114
|
-
a.link(b)
|
115
|
-
event = Timeout.timeout(5) do
|
116
|
-
client.wait_event('celluloid.events.actors_linked', a, b)
|
117
|
-
end
|
118
|
-
event.should_not == nil
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Celluloid::Properties do
|
4
|
-
let(:default_value) { 42 }
|
5
|
-
let(:changed_value) { 43 }
|
6
|
-
|
7
|
-
let(:example_class) do
|
8
|
-
Class.new do
|
9
|
-
extend Celluloid::Properties
|
10
|
-
property :baz, :default => 42
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:example_subclass) do
|
15
|
-
Class.new(example_class)
|
16
|
-
end
|
17
|
-
|
18
|
-
let(:example_subclass_subclass) do
|
19
|
-
Class.new(example_subclass)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "adds properties to classes" do
|
23
|
-
example_class.baz.should eq default_value
|
24
|
-
example_class.baz changed_value
|
25
|
-
example_class.baz.should eq changed_value
|
26
|
-
end
|
27
|
-
|
28
|
-
it "allows properties to be inherited" do
|
29
|
-
example_subclass.baz.should eq default_value
|
30
|
-
example_subclass.baz changed_value
|
31
|
-
example_subclass.baz.should eq changed_value
|
32
|
-
example_class.baz.should eq default_value
|
33
|
-
end
|
34
|
-
|
35
|
-
it "allows properties to be deeply inherited" do
|
36
|
-
example_subclass_subclass.baz.should eq default_value
|
37
|
-
example_subclass_subclass.baz changed_value
|
38
|
-
example_subclass_subclass.baz.should eq changed_value
|
39
|
-
example_subclass.baz.should eq default_value
|
40
|
-
example_class.baz.should eq default_value
|
41
|
-
end
|
42
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Celluloid::Registry, actor_system: :global do
|
4
|
-
class Marilyn
|
5
|
-
include Celluloid
|
6
|
-
|
7
|
-
def sing_for(person)
|
8
|
-
"o/~ Happy birthday, #{person}"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it "registers Actors" do
|
13
|
-
Celluloid::Actor[:marilyn] = Marilyn.new
|
14
|
-
Celluloid::Actor[:marilyn].sing_for("Mr. President").should == "o/~ Happy birthday, Mr. President"
|
15
|
-
end
|
16
|
-
|
17
|
-
it "refuses to register non-Actors" do
|
18
|
-
expect do
|
19
|
-
Celluloid::Actor[:impostor] = Object.new
|
20
|
-
end.to raise_error TypeError
|
21
|
-
end
|
22
|
-
|
23
|
-
it "lists all registered actors" do
|
24
|
-
Celluloid::Actor[:marilyn] = Marilyn.new
|
25
|
-
Celluloid::Actor.registered.should include :marilyn
|
26
|
-
end
|
27
|
-
|
28
|
-
it "knows its name once registered" do
|
29
|
-
Celluloid::Actor[:marilyn] = Marilyn.new
|
30
|
-
Celluloid::Actor[:marilyn].registered_name.should == :marilyn
|
31
|
-
end
|
32
|
-
|
33
|
-
describe :delete do
|
34
|
-
before do
|
35
|
-
Celluloid::Actor[:marilyn] ||= Marilyn.new
|
36
|
-
end
|
37
|
-
|
38
|
-
it "removes reference to actors' name from the registry" do
|
39
|
-
Celluloid::Actor.delete(:marilyn)
|
40
|
-
Celluloid::Actor.registered.should_not include :marilyn
|
41
|
-
end
|
42
|
-
|
43
|
-
it "returns actor removed from the registry" do
|
44
|
-
rval = Celluloid::Actor.delete(:marilyn)
|
45
|
-
rval.should be_kind_of(Marilyn)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe :clear do
|
50
|
-
it "should return a hash of registered actors and remove them from the registry" do
|
51
|
-
Celluloid::Actor[:marilyn] ||= Marilyn.new
|
52
|
-
rval = Celluloid::Actor.clear_registry
|
53
|
-
begin
|
54
|
-
rval.should be_kind_of(Hash)
|
55
|
-
rval.should have_key(:marilyn)
|
56
|
-
rval[:marilyn].wrapped_object.should be_instance_of(Marilyn)
|
57
|
-
Celluloid::Actor.registered.should be_empty
|
58
|
-
ensure
|
59
|
-
# Repopulate the registry once we're done
|
60
|
-
rval.each { |key, actor| Celluloid::Actor[key] = actor }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Celluloid::StackDump do
|
4
|
-
let(:actor_system) do
|
5
|
-
Celluloid::ActorSystem.new
|
6
|
-
end
|
7
|
-
|
8
|
-
subject do
|
9
|
-
actor_system.stack_dump
|
10
|
-
end
|
11
|
-
|
12
|
-
class BlockingActor
|
13
|
-
include Celluloid
|
14
|
-
|
15
|
-
def blocking
|
16
|
-
Kernel.sleep
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
before(:each) do
|
21
|
-
[Celluloid::TaskFiber, Celluloid::TaskThread].each do |task_klass|
|
22
|
-
actor_klass = Class.new(BlockingActor) do
|
23
|
-
task_class task_klass
|
24
|
-
end
|
25
|
-
actor = actor_system.within do
|
26
|
-
actor_klass.new
|
27
|
-
end
|
28
|
-
actor.async.blocking
|
29
|
-
end
|
30
|
-
|
31
|
-
@active_thread = actor_system.get_thread do
|
32
|
-
sleep
|
33
|
-
end
|
34
|
-
@active_thread.role = :other_thing
|
35
|
-
@idle_thread = actor_system.get_thread do
|
36
|
-
end
|
37
|
-
|
38
|
-
sleep 0.01
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#actors' do
|
42
|
-
it 'should include all actors' do
|
43
|
-
subject.actors.size.should == actor_system.running.size
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#threads' do
|
48
|
-
it 'should include threads that are not actors', pending: 'flaky' do
|
49
|
-
expect(subject.threads.size).to eq(3)
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should include idle threads' do
|
53
|
-
subject.threads.map(&:thread_id).should include(@idle_thread.object_id)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should include threads checked out of the pool for roles other than :actor' do
|
57
|
-
subject.threads.map(&:thread_id).should include(@active_thread.object_id)
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'should have the correct roles', pending: 'flaky' do
|
61
|
-
expect(subject.threads.map(&:role)).to include(nil, :other_thing, :task)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Celluloid::SupervisionGroup, actor_system: :global do
|
4
|
-
before :all do
|
5
|
-
class MyActor
|
6
|
-
include Celluloid
|
7
|
-
|
8
|
-
def running?; :yep; end
|
9
|
-
end
|
10
|
-
|
11
|
-
class MyGroup < Celluloid::SupervisionGroup
|
12
|
-
supervise MyActor, :as => :example
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it "runs applications" do
|
17
|
-
MyGroup.run!
|
18
|
-
sleep 0.01 # startup time hax
|
19
|
-
|
20
|
-
Celluloid::Actor[:example].should be_running
|
21
|
-
end
|
22
|
-
|
23
|
-
it "accepts a private actor registry" do
|
24
|
-
my_registry = Celluloid::Registry.new
|
25
|
-
MyGroup.run!(my_registry)
|
26
|
-
sleep 0.01
|
27
|
-
|
28
|
-
my_registry[:example].should be_running
|
29
|
-
end
|
30
|
-
|
31
|
-
it "removes actors from the registry when terminating" do
|
32
|
-
group = MyGroup.run!
|
33
|
-
group.terminate
|
34
|
-
Celluloid::Actor[:example].should be_nil
|
35
|
-
end
|
36
|
-
|
37
|
-
context "pool" do
|
38
|
-
before :all do
|
39
|
-
class MyActor
|
40
|
-
attr_reader :args
|
41
|
-
def initialize *args
|
42
|
-
@args = *args
|
43
|
-
end
|
44
|
-
end
|
45
|
-
class MyGroup
|
46
|
-
pool MyActor, :as => :example_pool, :args => 'foo', :size => 3
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
it "runs applications and passes pool options and actor args" do
|
51
|
-
MyGroup.run!
|
52
|
-
sleep 0.001 # startup time hax
|
53
|
-
|
54
|
-
Celluloid::Actor[:example_pool].should be_running
|
55
|
-
Celluloid::Actor[:example_pool].args.should eq ['foo']
|
56
|
-
Celluloid::Actor[:example_pool].size.should be 3
|
57
|
-
end
|
58
|
-
|
59
|
-
it "allows external access to the internal registry" do
|
60
|
-
supervisor = MyGroup.run!
|
61
|
-
|
62
|
-
supervisor[:example].should be_a MyActor
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|