celluloid 0.15.2 → 0.16.0.pre2

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +20 -0
  3. data/README.md +25 -2
  4. data/lib/celluloid/actor.rb +86 -133
  5. data/lib/celluloid/actor_system.rb +107 -0
  6. data/lib/celluloid/call_chain.rb +1 -1
  7. data/lib/celluloid/calls.rb +16 -16
  8. data/lib/celluloid/cell.rb +89 -0
  9. data/lib/celluloid/condition.rb +25 -8
  10. data/lib/celluloid/cpu_counter.rb +27 -18
  11. data/lib/celluloid/evented_mailbox.rb +8 -15
  12. data/lib/celluloid/exceptions.rb +23 -0
  13. data/lib/celluloid/future.rb +1 -1
  14. data/lib/celluloid/handlers.rb +41 -0
  15. data/lib/celluloid/internal_pool.rb +0 -3
  16. data/lib/celluloid/logger.rb +30 -0
  17. data/lib/celluloid/logging/incident_logger.rb +1 -1
  18. data/lib/celluloid/mailbox.rb +19 -18
  19. data/lib/celluloid/method.rb +8 -0
  20. data/lib/celluloid/pool_manager.rb +19 -2
  21. data/lib/celluloid/probe.rb +73 -0
  22. data/lib/celluloid/properties.rb +2 -2
  23. data/lib/celluloid/proxies/actor_proxy.rb +9 -41
  24. data/lib/celluloid/proxies/cell_proxy.rb +68 -0
  25. data/lib/celluloid/proxies/sync_proxy.rb +1 -1
  26. data/lib/celluloid/receivers.rb +3 -1
  27. data/lib/celluloid/registry.rb +1 -8
  28. data/lib/celluloid/stack_dump.rb +34 -11
  29. data/lib/celluloid/supervision_group.rb +26 -14
  30. data/lib/celluloid/tasks/task_fiber.rb +6 -0
  31. data/lib/celluloid/tasks/task_thread.rb +2 -1
  32. data/lib/celluloid/tasks.rb +6 -9
  33. data/lib/celluloid/thread_handle.rb +2 -2
  34. data/lib/celluloid.rb +68 -73
  35. data/spec/celluloid/actor_spec.rb +1 -1
  36. data/spec/celluloid/actor_system_spec.rb +69 -0
  37. data/spec/celluloid/block_spec.rb +1 -1
  38. data/spec/celluloid/calls_spec.rb +1 -1
  39. data/spec/celluloid/condition_spec.rb +14 -3
  40. data/spec/celluloid/cpu_counter_spec.rb +82 -0
  41. data/spec/celluloid/fsm_spec.rb +1 -1
  42. data/spec/celluloid/future_spec.rb +1 -1
  43. data/spec/celluloid/notifications_spec.rb +1 -1
  44. data/spec/celluloid/pool_spec.rb +34 -1
  45. data/spec/celluloid/probe_spec.rb +121 -0
  46. data/spec/celluloid/registry_spec.rb +6 -6
  47. data/spec/celluloid/stack_dump_spec.rb +37 -8
  48. data/spec/celluloid/supervision_group_spec.rb +7 -1
  49. data/spec/celluloid/supervisor_spec.rb +12 -1
  50. data/spec/celluloid/tasks/task_fiber_spec.rb +1 -1
  51. data/spec/celluloid/tasks/task_thread_spec.rb +1 -1
  52. data/spec/celluloid/thread_handle_spec.rb +7 -3
  53. data/spec/spec_helper.rb +20 -7
  54. data/spec/support/actor_examples.rb +33 -15
  55. data/spec/support/mailbox_examples.rb +9 -3
  56. data/spec/support/task_examples.rb +2 -0
  57. metadata +46 -22
@@ -65,6 +65,19 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
65
65
  method.arity.should be(1)
66
66
  end
67
67
 
68
+ it "supports #name calls via #method" do
69
+ method = actor_class.new("Troy McClure").method(:greet)
70
+ method.name.should == :greet
71
+ end
72
+
73
+ it "supports #parameters via #method" do
74
+ method = actor_class.new("Troy McClure").method(:greet)
75
+ method.parameters.should == []
76
+
77
+ method = actor_class.new("Troy McClure").method(:change_name)
78
+ method.parameters.should == [[:req, :new_name]]
79
+ end
80
+
68
81
  it "supports future(:method) syntax for synchronous future calls" do
69
82
  actor = actor_class.new "Troy McClure"
70
83
  future = actor.future :greet
@@ -148,7 +161,6 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
148
161
  end
149
162
  end
150
163
 
151
- Celluloid.logger = double.as_null_object
152
164
  Celluloid.logger.should_receive(:warn).with(/Dangerously suspending task: type=:call, meta={:method_name=>:initialize}, status=:sleeping/)
153
165
 
154
166
  actor = klass.new
@@ -175,7 +187,6 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
175
187
  end
176
188
  end
177
189
 
178
- Celluloid.logger = double.as_null_object
179
190
  Celluloid.logger.should_receive(:warn).with(/Dangerously suspending task: type=:finalizer, meta={:method_name=>:cleanup}, status=:sleeping/)
180
191
 
181
192
  actor = klass.new
@@ -221,7 +232,7 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
221
232
 
222
233
  it "inspects properly" do
223
234
  actor = actor_class.new "Troy McClure"
224
- actor.inspect.should match(/Celluloid::ActorProxy\(/)
235
+ actor.inspect.should match(/Celluloid::CellProxy\(/)
225
236
  actor.inspect.should match(/#{actor_class}/)
226
237
  actor.inspect.should include('@name="Troy McClure"')
227
238
  actor.inspect.should_not include("@celluloid")
@@ -230,7 +241,7 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
230
241
  it "inspects properly when dead" do
231
242
  actor = actor_class.new "Troy McClure"
232
243
  actor.terminate
233
- actor.inspect.should match(/Celluloid::ActorProxy\(/)
244
+ actor.inspect.should match(/Celluloid::CellProxy\(/)
234
245
  actor.inspect.should match(/#{actor_class}/)
235
246
  actor.inspect.should include('dead')
236
247
  end
@@ -252,7 +263,7 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
252
263
  itchy.other = scratchy
253
264
 
254
265
  inspection = itchy.inspect
255
- inspection.should match(/Celluloid::ActorProxy\(/)
266
+ inspection.should match(/Celluloid::CellProxy\(/)
256
267
  inspection.should include("...")
257
268
  end
258
269
 
@@ -300,27 +311,27 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
300
311
  end
301
312
 
302
313
  it "includes both sender and receiver in exception traces" do
303
- ExampleReceiver = Class.new do
314
+ example_receiver = Class.new do
304
315
  include included_module
305
316
  task_class task_klass
306
317
 
307
- def receiver_method
318
+ define_method(:receiver_method) do
308
319
  raise ExampleCrash, "the spec purposely crashed me :("
309
320
  end
310
321
  end
311
322
 
312
- ExampleCaller = Class.new do
323
+ excample_caller = Class.new do
313
324
  include included_module
314
325
  task_class task_klass
315
326
 
316
- def sender_method
317
- ExampleReceiver.new.receiver_method
327
+ define_method(:sender_method) do
328
+ example_receiver.new.receiver_method
318
329
  end
319
330
  end
320
331
 
321
332
  ex = nil
322
333
  begin
323
- ExampleCaller.new.sender_method
334
+ excample_caller.new.sender_method
324
335
  rescue => ex
325
336
  end
326
337
 
@@ -404,6 +415,15 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
404
415
  end.to raise_exception(Celluloid::DeadActorError)
405
416
  end
406
417
 
418
+ it "terminates cleanly on Celluloid shutdown" do
419
+ Celluloid::Actor.stub(:kill).and_call_original
420
+
421
+ actor = actor_class.new "Arnold Schwarzenegger"
422
+
423
+ Celluloid.shutdown
424
+ Celluloid::Actor.should_not have_received(:kill)
425
+ end
426
+
407
427
  it "raises the right DeadActorError if terminate! called after terminated" do
408
428
  actor = actor_class.new "Arnold Schwarzenegger"
409
429
  actor.terminate
@@ -414,8 +434,7 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
414
434
  end
415
435
 
416
436
  it "logs a warning when terminating tasks" do
417
- Celluloid.logger = double.as_null_object
418
- Celluloid.logger.should_receive(:warn).with("Terminating task: type=:call, meta={:method_name=>:sleepy}, status=:sleeping")
437
+ Celluloid.logger.should_receive(:warn).with(/^Terminating task: type=:call, meta={:method_name=>:sleepy}, status=:sleeping\n/)
419
438
 
420
439
  actor = actor_class.new "Arnold Schwarzenegger"
421
440
  actor.async.sleepy 10
@@ -923,7 +942,7 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
923
942
  end
924
943
 
925
944
  context :proxy_class do
926
- class ExampleProxy < Celluloid::ActorProxy
945
+ class ExampleProxy < Celluloid::CellProxy
927
946
  def subclass_proxy?
928
947
  true
929
948
  end
@@ -1000,7 +1019,6 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
1000
1019
 
1001
1020
  context "raw message sends" do
1002
1021
  it "logs on unhandled messages" do
1003
- Celluloid.logger = double.as_null_object
1004
1022
  Celluloid.logger.should_receive(:debug).with("Discarded message (unhandled): first")
1005
1023
 
1006
1024
  actor = actor_class.new "Irma Gladden"
@@ -1,4 +1,9 @@
1
1
  shared_context "a Celluloid Mailbox" do
2
+ after do
3
+ Celluloid.logger.stub(:debug)
4
+ subject.shutdown if subject.alive?
5
+ end
6
+
2
7
  it "receives messages" do
3
8
  message = :ohai
4
9
 
@@ -34,7 +39,10 @@ shared_context "a Celluloid Mailbox" do
34
39
  interval = 0.1
35
40
  started_at = Time.now
36
41
 
37
- subject.receive(interval) { false }
42
+ expect do
43
+ subject.receive(interval) { false }
44
+ end.to raise_exception(Celluloid::TimeoutError)
45
+
38
46
  (Time.now - started_at).should be_within(Celluloid::TIMER_QUANTUM).of interval
39
47
  end
40
48
 
@@ -55,7 +63,6 @@ shared_context "a Celluloid Mailbox" do
55
63
  end
56
64
 
57
65
  it "logs discarded messages" do
58
- Celluloid.logger = double.as_null_object
59
66
  Celluloid.logger.should_receive(:debug).with("Discarded message (mailbox is dead): third")
60
67
 
61
68
  subject.max_size = 2
@@ -65,7 +72,6 @@ shared_context "a Celluloid Mailbox" do
65
72
  end
66
73
 
67
74
  it "discard messages when dead" do
68
- Celluloid.logger = double.as_null_object
69
75
  Celluloid.logger.should_receive(:debug).with("Discarded message (mailbox is dead): first")
70
76
  Celluloid.logger.should_receive(:debug).with("Discarded message (mailbox is dead): second")
71
77
  Celluloid.logger.should_receive(:debug).with("Discarded message (mailbox is dead): third")
@@ -17,11 +17,13 @@ shared_context "a Celluloid Task" do |task_class|
17
17
  subject { task_class.new(task_type, {}) { Celluloid::Task.suspend(suspend_state) } }
18
18
 
19
19
  before :each do
20
+ Thread.current[:celluloid_actor_system] = Celluloid.actor_system
20
21
  Thread.current[:celluloid_actor] = actor
21
22
  end
22
23
 
23
24
  after :each do
24
25
  Thread.current[:celluloid_actor] = nil
26
+ Thread.current[:celluloid_actor_system] = nil
25
27
  end
26
28
 
27
29
  it "begins with status :new" do
metadata CHANGED
@@ -1,83 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.16.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-06 00:00:00.000000000 Z
11
+ date: 2014-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timers
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.0
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 2.14.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 2.14.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: benchmark_suite
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  description: Celluloid enables people to build concurrent programs out of concurrent
@@ -88,37 +102,45 @@ executables: []
88
102
  extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
105
+ - LICENSE.txt
91
106
  - README.md
107
+ - lib/celluloid.rb
92
108
  - lib/celluloid/actor.rb
109
+ - lib/celluloid/actor_system.rb
93
110
  - lib/celluloid/autostart.rb
94
111
  - lib/celluloid/call_chain.rb
95
112
  - lib/celluloid/calls.rb
113
+ - lib/celluloid/cell.rb
96
114
  - lib/celluloid/condition.rb
97
115
  - lib/celluloid/core_ext.rb
98
116
  - lib/celluloid/cpu_counter.rb
99
117
  - lib/celluloid/evented_mailbox.rb
118
+ - lib/celluloid/exceptions.rb
100
119
  - lib/celluloid/fiber.rb
101
120
  - lib/celluloid/fsm.rb
102
121
  - lib/celluloid/future.rb
122
+ - lib/celluloid/handlers.rb
103
123
  - lib/celluloid/internal_pool.rb
104
124
  - lib/celluloid/legacy.rb
105
125
  - lib/celluloid/links.rb
106
126
  - lib/celluloid/logger.rb
127
+ - lib/celluloid/logging.rb
107
128
  - lib/celluloid/logging/incident.rb
108
129
  - lib/celluloid/logging/incident_logger.rb
109
130
  - lib/celluloid/logging/incident_reporter.rb
110
131
  - lib/celluloid/logging/log_event.rb
111
132
  - lib/celluloid/logging/ring_buffer.rb
112
- - lib/celluloid/logging.rb
113
133
  - lib/celluloid/mailbox.rb
114
134
  - lib/celluloid/method.rb
115
135
  - lib/celluloid/notifications.rb
116
136
  - lib/celluloid/pool_manager.rb
137
+ - lib/celluloid/probe.rb
117
138
  - lib/celluloid/properties.rb
118
139
  - lib/celluloid/proxies/abstract_proxy.rb
119
140
  - lib/celluloid/proxies/actor_proxy.rb
120
141
  - lib/celluloid/proxies/async_proxy.rb
121
142
  - lib/celluloid/proxies/block_proxy.rb
143
+ - lib/celluloid/proxies/cell_proxy.rb
122
144
  - lib/celluloid/proxies/future_proxy.rb
123
145
  - lib/celluloid/proxies/sync_proxy.rb
124
146
  - lib/celluloid/receivers.rb
@@ -131,18 +153,19 @@ files:
131
153
  - lib/celluloid/supervisor.rb
132
154
  - lib/celluloid/system_events.rb
133
155
  - lib/celluloid/task_set.rb
156
+ - lib/celluloid/tasks.rb
134
157
  - lib/celluloid/tasks/task_fiber.rb
135
158
  - lib/celluloid/tasks/task_thread.rb
136
- - lib/celluloid/tasks.rb
137
159
  - lib/celluloid/test.rb
138
160
  - lib/celluloid/thread.rb
139
161
  - lib/celluloid/thread_handle.rb
140
162
  - lib/celluloid/uuid.rb
141
- - lib/celluloid.rb
142
163
  - spec/celluloid/actor_spec.rb
164
+ - spec/celluloid/actor_system_spec.rb
143
165
  - spec/celluloid/block_spec.rb
144
166
  - spec/celluloid/calls_spec.rb
145
167
  - spec/celluloid/condition_spec.rb
168
+ - spec/celluloid/cpu_counter_spec.rb
146
169
  - spec/celluloid/evented_mailbox_spec.rb
147
170
  - spec/celluloid/fsm_spec.rb
148
171
  - spec/celluloid/future_spec.rb
@@ -152,6 +175,7 @@ files:
152
175
  - spec/celluloid/mailbox_spec.rb
153
176
  - spec/celluloid/notifications_spec.rb
154
177
  - spec/celluloid/pool_spec.rb
178
+ - spec/celluloid/probe_spec.rb
155
179
  - spec/celluloid/properties_spec.rb
156
180
  - spec/celluloid/registry_spec.rb
157
181
  - spec/celluloid/stack_dump_spec.rb
@@ -176,17 +200,17 @@ require_paths:
176
200
  - lib
177
201
  required_ruby_version: !ruby/object:Gem::Requirement
178
202
  requirements:
179
- - - '>='
203
+ - - ">="
180
204
  - !ruby/object:Gem::Version
181
205
  version: 1.9.2
182
206
  required_rubygems_version: !ruby/object:Gem::Requirement
183
207
  requirements:
184
- - - '>='
208
+ - - ">="
185
209
  - !ruby/object:Gem::Version
186
210
  version: 1.3.6
187
211
  requirements: []
188
212
  rubyforge_project:
189
- rubygems_version: 2.0.3
213
+ rubygems_version: 2.2.2
190
214
  signing_key:
191
215
  specification_version: 4
192
216
  summary: Actor-based concurrent object framework for Ruby