celluloid 0.16.0 → 0.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +394 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +28 -15
  5. data/culture/CONDUCT.md +28 -0
  6. data/culture/Gemfile +9 -0
  7. data/culture/LICENSE.txt +22 -0
  8. data/culture/README.md +22 -0
  9. data/culture/Rakefile +5 -0
  10. data/culture/SYNC.md +70 -0
  11. data/culture/celluloid-culture.gemspec +18 -0
  12. data/culture/gems/README.md +39 -0
  13. data/culture/gems/dependencies.yml +85 -0
  14. data/culture/gems/loader.rb +101 -0
  15. data/culture/rubocop/README.md +38 -0
  16. data/culture/rubocop/lint.yml +8 -0
  17. data/culture/rubocop/metrics.yml +15 -0
  18. data/culture/rubocop/perf.yml +0 -0
  19. data/culture/rubocop/rubocop.yml +5 -0
  20. data/culture/rubocop/style.yml +57 -0
  21. data/culture/spec/gems_spec.rb +2 -0
  22. data/culture/spec/spec_helper.rb +0 -0
  23. data/culture/spec/sync_spec.rb +2 -0
  24. data/culture/sync.rb +56 -0
  25. data/culture/tasks/rspec.rake +5 -0
  26. data/culture/tasks/rubocop.rake +2 -0
  27. data/examples/basic_usage.rb +49 -0
  28. data/examples/futures.rb +38 -0
  29. data/examples/ring.rb +61 -0
  30. data/examples/simple_pmap.rb +14 -0
  31. data/examples/stack.rb +47 -0
  32. data/examples/timers.rb +72 -0
  33. data/lib/celluloid/actor/manager.rb +7 -0
  34. data/lib/celluloid/actor/system.rb +163 -0
  35. data/lib/celluloid/actor.rb +53 -71
  36. data/lib/celluloid/autostart.rb +1 -1
  37. data/lib/celluloid/backported.rb +2 -0
  38. data/lib/celluloid/call/async.rb +16 -0
  39. data/lib/celluloid/call/block.rb +22 -0
  40. data/lib/celluloid/call/sync.rb +70 -0
  41. data/lib/celluloid/calls.rb +24 -114
  42. data/lib/celluloid/cell.rb +32 -20
  43. data/lib/celluloid/condition.rb +5 -6
  44. data/lib/celluloid/core_ext.rb +1 -1
  45. data/lib/celluloid/current.rb +2 -0
  46. data/lib/celluloid/debug.rb +1 -0
  47. data/lib/celluloid/deprecate.rb +21 -0
  48. data/lib/celluloid/exceptions.rb +22 -16
  49. data/lib/celluloid/fiber.rb +3 -3
  50. data/lib/celluloid/future.rb +46 -8
  51. data/lib/celluloid/group/pool.rb +125 -0
  52. data/lib/celluloid/group/spawner.rb +68 -0
  53. data/lib/celluloid/group.rb +61 -0
  54. data/lib/celluloid/logging.rb +5 -5
  55. data/lib/celluloid/mailbox/evented.rb +74 -0
  56. data/lib/celluloid/mailbox.rb +15 -14
  57. data/lib/celluloid/managed.rb +3 -0
  58. data/lib/celluloid/notices.rb +15 -0
  59. data/lib/celluloid/proxies.rb +11 -0
  60. data/lib/celluloid/proxy/abstract.rb +50 -0
  61. data/lib/celluloid/proxy/actor.rb +37 -0
  62. data/lib/celluloid/proxy/async.rb +15 -0
  63. data/lib/celluloid/proxy/block.rb +28 -0
  64. data/lib/celluloid/proxy/cell.rb +66 -0
  65. data/lib/celluloid/proxy/future.rb +20 -0
  66. data/lib/celluloid/proxy/sync.rb +24 -0
  67. data/lib/celluloid/rspec.rb +67 -9
  68. data/lib/celluloid/system_events.rb +69 -14
  69. data/lib/celluloid/task/fibered.rb +45 -0
  70. data/lib/celluloid/task/threaded.rb +59 -0
  71. data/lib/celluloid/{tasks.rb → task.rb} +30 -38
  72. data/lib/celluloid/test.rb +1 -1
  73. data/lib/celluloid/thread.rb +6 -1
  74. data/lib/celluloid/version.rb +3 -0
  75. data/lib/celluloid.rb +151 -130
  76. data/spec/celluloid/actor/system_spec.rb +83 -0
  77. data/spec/celluloid/actor_spec.rb +2 -2
  78. data/spec/celluloid/block_spec.rb +67 -8
  79. data/spec/celluloid/calls_spec.rb +28 -23
  80. data/spec/celluloid/condition_spec.rb +23 -14
  81. data/spec/celluloid/evented_mailbox_spec.rb +1 -31
  82. data/spec/celluloid/future_spec.rb +15 -12
  83. data/spec/celluloid/group/elastic_spec.rb +0 -0
  84. data/spec/celluloid/group/pool_spec.rb +8 -0
  85. data/spec/celluloid/group/spawner_spec.rb +17 -0
  86. data/spec/celluloid/mailbox/evented_spec.rb +40 -0
  87. data/spec/celluloid/mailbox_spec.rb +1 -3
  88. data/spec/celluloid/misc/leak_spec.rb +73 -0
  89. data/spec/celluloid/proxy_spec.rb +33 -0
  90. data/spec/celluloid/task/fibered_spec.rb +5 -0
  91. data/spec/celluloid/task/threaded_spec.rb +5 -0
  92. data/spec/celluloid/timer_spec.rb +14 -16
  93. data/spec/deprecate/actor_system_spec.rb +72 -0
  94. data/spec/deprecate/block_spec.rb +52 -0
  95. data/spec/deprecate/calls_spec.rb +39 -0
  96. data/spec/deprecate/evented_mailbox_spec.rb +34 -0
  97. data/spec/deprecate/future_spec.rb +32 -0
  98. data/spec/deprecate/internal_pool_spec.rb +4 -0
  99. data/spec/shared/actor_examples.rb +1259 -0
  100. data/spec/shared/group_examples.rb +121 -0
  101. data/spec/shared/mailbox_examples.rb +87 -0
  102. data/{lib/celluloid/rspec → spec/shared}/task_examples.rb +9 -8
  103. data/spec/spec_helper.rb +5 -42
  104. data/spec/support/configure_rspec.rb +77 -0
  105. data/spec/support/coverage.rb +4 -0
  106. data/spec/support/crash_checking.rb +68 -0
  107. data/spec/support/debugging.rb +31 -0
  108. data/spec/support/env.rb +21 -0
  109. data/{lib/celluloid/rspec/example_actor_class.rb → spec/support/examples/actor_class.rb} +21 -2
  110. data/spec/support/examples/call_class.rb +37 -0
  111. data/spec/support/examples/evented_mailbox_class.rb +27 -0
  112. data/spec/support/includer.rb +6 -0
  113. data/spec/support/logging.rb +55 -0
  114. data/spec/support/loose_threads.rb +68 -0
  115. data/spec/support/reset_class_variables.rb +27 -0
  116. data/spec/support/sleep_and_wait.rb +14 -0
  117. data/spec/support/stubbing.rb +14 -0
  118. metadata +276 -78
  119. data/lib/celluloid/actor_system.rb +0 -107
  120. data/lib/celluloid/call_chain.rb +0 -13
  121. data/lib/celluloid/cpu_counter.rb +0 -34
  122. data/lib/celluloid/evented_mailbox.rb +0 -73
  123. data/lib/celluloid/fsm.rb +0 -186
  124. data/lib/celluloid/handlers.rb +0 -41
  125. data/lib/celluloid/internal_pool.rb +0 -159
  126. data/lib/celluloid/legacy.rb +0 -9
  127. data/lib/celluloid/links.rb +0 -36
  128. data/lib/celluloid/logger.rb +0 -93
  129. data/lib/celluloid/logging/incident.rb +0 -21
  130. data/lib/celluloid/logging/incident_logger.rb +0 -129
  131. data/lib/celluloid/logging/incident_reporter.rb +0 -48
  132. data/lib/celluloid/logging/log_event.rb +0 -20
  133. data/lib/celluloid/logging/ring_buffer.rb +0 -65
  134. data/lib/celluloid/method.rb +0 -32
  135. data/lib/celluloid/notifications.rb +0 -83
  136. data/lib/celluloid/pool_manager.rb +0 -146
  137. data/lib/celluloid/probe.rb +0 -73
  138. data/lib/celluloid/properties.rb +0 -24
  139. data/lib/celluloid/proxies/abstract_proxy.rb +0 -20
  140. data/lib/celluloid/proxies/actor_proxy.rb +0 -38
  141. data/lib/celluloid/proxies/async_proxy.rb +0 -31
  142. data/lib/celluloid/proxies/block_proxy.rb +0 -29
  143. data/lib/celluloid/proxies/cell_proxy.rb +0 -68
  144. data/lib/celluloid/proxies/future_proxy.rb +0 -35
  145. data/lib/celluloid/proxies/sync_proxy.rb +0 -36
  146. data/lib/celluloid/receivers.rb +0 -63
  147. data/lib/celluloid/registry.rb +0 -57
  148. data/lib/celluloid/responses.rb +0 -44
  149. data/lib/celluloid/rspec/actor_examples.rb +0 -1054
  150. data/lib/celluloid/rspec/mailbox_examples.rb +0 -84
  151. data/lib/celluloid/signals.rb +0 -23
  152. data/lib/celluloid/stack_dump.rb +0 -133
  153. data/lib/celluloid/supervision_group.rb +0 -169
  154. data/lib/celluloid/supervisor.rb +0 -22
  155. data/lib/celluloid/task_set.rb +0 -49
  156. data/lib/celluloid/tasks/task_fiber.rb +0 -43
  157. data/lib/celluloid/tasks/task_thread.rb +0 -53
  158. data/lib/celluloid/thread_handle.rb +0 -50
  159. data/lib/celluloid/uuid.rb +0 -38
  160. data/spec/celluloid/actor_system_spec.rb +0 -69
  161. data/spec/celluloid/cpu_counter_spec.rb +0 -82
  162. data/spec/celluloid/fsm_spec.rb +0 -107
  163. data/spec/celluloid/internal_pool_spec.rb +0 -52
  164. data/spec/celluloid/links_spec.rb +0 -45
  165. data/spec/celluloid/logging/ring_buffer_spec.rb +0 -38
  166. data/spec/celluloid/notifications_spec.rb +0 -120
  167. data/spec/celluloid/pool_spec.rb +0 -92
  168. data/spec/celluloid/probe_spec.rb +0 -121
  169. data/spec/celluloid/properties_spec.rb +0 -42
  170. data/spec/celluloid/registry_spec.rb +0 -64
  171. data/spec/celluloid/stack_dump_spec.rb +0 -64
  172. data/spec/celluloid/supervision_group_spec.rb +0 -65
  173. data/spec/celluloid/supervisor_spec.rb +0 -103
  174. data/spec/celluloid/tasks/task_fiber_spec.rb +0 -5
  175. data/spec/celluloid/tasks/task_thread_spec.rb +0 -5
  176. data/spec/celluloid/thread_handle_spec.rb +0 -26
  177. data/spec/celluloid/uuid_spec.rb +0 -11
@@ -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
@@ -1,103 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Celluloid::Supervisor, actor_system: :global do
4
- class SubordinateDead < StandardError; end
5
-
6
- class Subordinate
7
- include Celluloid
8
- attr_reader :state
9
-
10
- def initialize(state)
11
- @state = state
12
- end
13
-
14
- def crack_the_whip
15
- case @state
16
- when :idle
17
- @state = :working
18
- else raise SubordinateDead, "the spec purposely crashed me :("
19
- end
20
- end
21
- end
22
-
23
- it "restarts actors when they die" do
24
- supervisor = Celluloid::Supervisor.supervise(Subordinate, :idle)
25
- subordinate = supervisor.actors.first
26
- subordinate.state.should be(:idle)
27
-
28
- subordinate.crack_the_whip
29
- subordinate.state.should be(:working)
30
-
31
- expect do
32
- subordinate.crack_the_whip
33
- end.to raise_exception(SubordinateDead)
34
- sleep 0.1 # hax to prevent race :(
35
- subordinate.should_not be_alive
36
-
37
- new_subordinate = supervisor.actors.first
38
- new_subordinate.should_not eq subordinate
39
- new_subordinate.state.should eq :idle
40
- end
41
-
42
- it "registers actors and reregisters them when they die" do
43
- Celluloid::Supervisor.supervise_as(:subordinate, Subordinate, :idle)
44
- subordinate = Celluloid::Actor[:subordinate]
45
- subordinate.state.should be(:idle)
46
-
47
- subordinate.crack_the_whip
48
- subordinate.state.should be(:working)
49
-
50
- expect do
51
- subordinate.crack_the_whip
52
- end.to raise_exception(SubordinateDead)
53
- sleep 0.1 # hax to prevent race :(
54
- subordinate.should_not be_alive
55
-
56
- new_subordinate = Celluloid::Actor[:subordinate]
57
- new_subordinate.should_not eq subordinate
58
- new_subordinate.state.should eq :idle
59
- end
60
-
61
- it "creates supervisors via Actor.supervise" do
62
- supervisor = Subordinate.supervise(:working)
63
- subordinate = supervisor.actors.first
64
- subordinate.state.should be(:working)
65
-
66
- expect do
67
- subordinate.crack_the_whip
68
- end.to raise_exception(SubordinateDead)
69
- sleep 0.1 # hax to prevent race :(
70
- subordinate.should_not be_alive
71
-
72
- new_subordinate = supervisor.actors.first
73
- new_subordinate.should_not eq subordinate
74
- new_subordinate.state.should eq :working
75
- end
76
-
77
- it "creates supervisors and registers actors via Actor.supervise_as" do
78
- supervisor = Subordinate.supervise_as(:subordinate, :working)
79
- subordinate = Celluloid::Actor[:subordinate]
80
- subordinate.state.should be(:working)
81
-
82
- expect do
83
- subordinate.crack_the_whip
84
- end.to raise_exception(SubordinateDead)
85
- sleep 0.1 # hax to prevent race :(
86
- subordinate.should_not be_alive
87
-
88
- new_subordinate = supervisor.actors.first
89
- new_subordinate.should_not eq subordinate
90
- new_subordinate.state.should be(:working)
91
- end
92
-
93
- it "removes an actor if it terminates cleanly" do
94
- supervisor = Subordinate.supervise(:working)
95
- subordinate = supervisor.actors.first
96
-
97
- supervisor.actors.should == [subordinate]
98
-
99
- subordinate.terminate
100
-
101
- supervisor.actors.should be_empty
102
- end
103
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Celluloid::TaskFiber, actor_system: :within do
4
- it_behaves_like "a Celluloid Task", Celluloid::TaskFiber
5
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Celluloid::TaskThread, actor_system: :within do
4
- it_behaves_like "a Celluloid Task", Celluloid::TaskThread
5
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Celluloid::ThreadHandle do
4
- let(:actor_system) do
5
- Celluloid::ActorSystem.new
6
- end
7
-
8
- it "knows thread liveliness" do
9
- queue = Queue.new
10
- handle = Celluloid::ThreadHandle.new(actor_system) { queue.pop }
11
- handle.should be_alive
12
-
13
- queue << :die
14
-
15
- sleep 0.01 # hax
16
- handle.should_not be_alive
17
- end
18
-
19
- it "joins to thread handles" do
20
- Celluloid::ThreadHandle.new(actor_system) { sleep 0.01 }.join
21
- end
22
-
23
- it "supports passing a role" do
24
- Celluloid::ThreadHandle.new(actor_system, :useful) { Thread.current.role.should == :useful }.join
25
- end
26
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Celluloid::UUID do
4
- U = Celluloid::UUID
5
-
6
- it "generates unique IDs across the BLOCK_SIZE boundary" do
7
- upper_bound = U::BLOCK_SIZE * 2 + 10
8
- uuids = (1..upper_bound).map{ U.generate }
9
- uuids.size.should == uuids.uniq.size
10
- end
11
- end