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.

Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +333 -0
  3. data/README.md +1 -1
  4. data/culture/CODE_OF_CONDUCT.md +28 -0
  5. data/culture/Gemfile +9 -0
  6. data/culture/README.md +22 -0
  7. data/culture/Rakefile +5 -0
  8. data/culture/SYNC.md +70 -0
  9. data/culture/celluloid-culture.gemspec +18 -0
  10. data/culture/gems/README.md +39 -0
  11. data/culture/gems/dependencies.yml +78 -0
  12. data/culture/gems/loader.rb +101 -0
  13. data/culture/rubocop/README.md +38 -0
  14. data/culture/rubocop/lint.yml +8 -0
  15. data/culture/rubocop/metrics.yml +15 -0
  16. data/culture/rubocop/rubocop.yml +4 -0
  17. data/culture/rubocop/style.yml +48 -0
  18. data/culture/spec/gems_spec.rb +2 -0
  19. data/culture/spec/spec_helper.rb +0 -0
  20. data/culture/spec/sync_spec.rb +2 -0
  21. data/culture/sync.rb +56 -0
  22. data/culture/tasks/rspec.rake +5 -0
  23. data/culture/tasks/rubocop.rake +2 -0
  24. data/examples/basic_usage.rb +49 -0
  25. data/examples/futures.rb +38 -0
  26. data/examples/ring.rb +61 -0
  27. data/examples/simple_pmap.rb +14 -0
  28. data/examples/timers.rb +72 -0
  29. data/lib/celluloid.rb +142 -127
  30. data/lib/celluloid/actor.rb +47 -41
  31. data/lib/celluloid/actor_system.rb +75 -22
  32. data/lib/celluloid/autostart.rb +1 -1
  33. data/lib/celluloid/backported.rb +2 -0
  34. data/lib/celluloid/call/async.rb +16 -0
  35. data/lib/celluloid/call/block.rb +22 -0
  36. data/lib/celluloid/call/sync.rb +70 -0
  37. data/lib/celluloid/calls.rb +25 -114
  38. data/lib/celluloid/cell.rb +32 -20
  39. data/lib/celluloid/condition.rb +3 -3
  40. data/lib/celluloid/core_ext.rb +1 -1
  41. data/lib/celluloid/current.rb +2 -0
  42. data/lib/celluloid/deprecate.rb +18 -0
  43. data/lib/celluloid/exceptions.rb +1 -1
  44. data/lib/celluloid/fiber.rb +3 -3
  45. data/lib/celluloid/future.rb +7 -6
  46. data/lib/celluloid/group.rb +65 -0
  47. data/lib/celluloid/group/manager.rb +27 -0
  48. data/lib/celluloid/group/pool.rb +125 -0
  49. data/lib/celluloid/group/spawner.rb +71 -0
  50. data/lib/celluloid/logging.rb +5 -5
  51. data/lib/celluloid/mailbox.rb +14 -13
  52. data/lib/celluloid/mailbox/evented.rb +76 -0
  53. data/lib/celluloid/notices.rb +15 -0
  54. data/lib/celluloid/proxies.rb +12 -0
  55. data/lib/celluloid/proxy/abstract.rb +24 -0
  56. data/lib/celluloid/proxy/actor.rb +46 -0
  57. data/lib/celluloid/proxy/async.rb +36 -0
  58. data/lib/celluloid/proxy/block.rb +31 -0
  59. data/lib/celluloid/proxy/cell.rb +76 -0
  60. data/lib/celluloid/proxy/future.rb +40 -0
  61. data/lib/celluloid/proxy/sync.rb +44 -0
  62. data/lib/celluloid/rspec.rb +9 -10
  63. data/lib/celluloid/system_events.rb +16 -15
  64. data/lib/celluloid/{tasks.rb → task.rb} +21 -21
  65. data/lib/celluloid/task/fibered.rb +45 -0
  66. data/lib/celluloid/task/threaded.rb +59 -0
  67. data/lib/celluloid/test.rb +1 -1
  68. data/lib/celluloid/thread.rb +6 -1
  69. data/lib/celluloid/version.rb +3 -0
  70. data/spec/celluloid/actor_spec.rb +2 -2
  71. data/spec/celluloid/actor_system_spec.rb +35 -21
  72. data/spec/celluloid/block_spec.rb +3 -5
  73. data/spec/celluloid/calls_spec.rb +33 -11
  74. data/spec/celluloid/condition_spec.rb +16 -13
  75. data/spec/celluloid/evented_mailbox_spec.rb +1 -31
  76. data/spec/celluloid/future_spec.rb +13 -10
  77. data/spec/celluloid/group/elastic_spec.rb +0 -0
  78. data/spec/celluloid/group/manager_spec.rb +0 -0
  79. data/spec/celluloid/group/pool_spec.rb +8 -0
  80. data/spec/celluloid/group/spawner_spec.rb +8 -0
  81. data/spec/celluloid/mailbox/evented_spec.rb +27 -0
  82. data/spec/celluloid/mailbox_spec.rb +1 -3
  83. data/spec/celluloid/misc/leak_spec.rb +73 -0
  84. data/spec/celluloid/task/fibered_spec.rb +5 -0
  85. data/spec/celluloid/task/threaded_spec.rb +5 -0
  86. data/spec/celluloid/timer_spec.rb +14 -16
  87. data/spec/deprecate/actor_system_spec.rb +72 -0
  88. data/spec/deprecate/block_spec.rb +52 -0
  89. data/spec/deprecate/calls_spec.rb +57 -0
  90. data/spec/deprecate/evented_mailbox_spec.rb +34 -0
  91. data/spec/deprecate/future_spec.rb +32 -0
  92. data/spec/deprecate/internal_pool_spec.rb +4 -0
  93. data/spec/shared/actor_examples.rb +1237 -0
  94. data/spec/shared/group_examples.rb +121 -0
  95. data/{lib/celluloid/rspec → spec/shared}/mailbox_examples.rb +20 -17
  96. data/{lib/celluloid/rspec → spec/shared}/task_examples.rb +9 -8
  97. data/spec/spec_helper.rb +72 -16
  98. data/spec/support/coverage.rb +4 -0
  99. data/spec/support/crash_checking.rb +68 -0
  100. data/spec/support/debugging.rb +31 -0
  101. data/spec/support/env.rb +16 -0
  102. data/{lib/celluloid/rspec/example_actor_class.rb → spec/support/examples/actor_class.rb} +21 -2
  103. data/spec/support/examples/evented_mailbox_class.rb +27 -0
  104. data/spec/support/includer.rb +9 -0
  105. data/spec/support/logging.rb +63 -0
  106. data/spec/support/loose_threads.rb +65 -0
  107. data/spec/support/reset_class_variables.rb +27 -0
  108. data/spec/support/sleep_and_wait.rb +14 -0
  109. data/spec/support/split_logs.rb +1 -0
  110. data/spec/support/stubbing.rb +14 -0
  111. metadata +255 -95
  112. data/lib/celluloid/call_chain.rb +0 -13
  113. data/lib/celluloid/cpu_counter.rb +0 -34
  114. data/lib/celluloid/evented_mailbox.rb +0 -73
  115. data/lib/celluloid/fsm.rb +0 -186
  116. data/lib/celluloid/handlers.rb +0 -41
  117. data/lib/celluloid/internal_pool.rb +0 -159
  118. data/lib/celluloid/legacy.rb +0 -9
  119. data/lib/celluloid/links.rb +0 -36
  120. data/lib/celluloid/logger.rb +0 -93
  121. data/lib/celluloid/logging/incident.rb +0 -21
  122. data/lib/celluloid/logging/incident_logger.rb +0 -129
  123. data/lib/celluloid/logging/incident_reporter.rb +0 -48
  124. data/lib/celluloid/logging/log_event.rb +0 -20
  125. data/lib/celluloid/logging/ring_buffer.rb +0 -65
  126. data/lib/celluloid/method.rb +0 -32
  127. data/lib/celluloid/notifications.rb +0 -83
  128. data/lib/celluloid/pool_manager.rb +0 -146
  129. data/lib/celluloid/probe.rb +0 -73
  130. data/lib/celluloid/properties.rb +0 -24
  131. data/lib/celluloid/proxies/abstract_proxy.rb +0 -20
  132. data/lib/celluloid/proxies/actor_proxy.rb +0 -38
  133. data/lib/celluloid/proxies/async_proxy.rb +0 -31
  134. data/lib/celluloid/proxies/block_proxy.rb +0 -29
  135. data/lib/celluloid/proxies/cell_proxy.rb +0 -68
  136. data/lib/celluloid/proxies/future_proxy.rb +0 -35
  137. data/lib/celluloid/proxies/sync_proxy.rb +0 -36
  138. data/lib/celluloid/receivers.rb +0 -63
  139. data/lib/celluloid/registry.rb +0 -57
  140. data/lib/celluloid/responses.rb +0 -44
  141. data/lib/celluloid/rspec/actor_examples.rb +0 -1054
  142. data/lib/celluloid/signals.rb +0 -23
  143. data/lib/celluloid/stack_dump.rb +0 -133
  144. data/lib/celluloid/supervision_group.rb +0 -169
  145. data/lib/celluloid/supervisor.rb +0 -22
  146. data/lib/celluloid/task_set.rb +0 -49
  147. data/lib/celluloid/tasks/task_fiber.rb +0 -43
  148. data/lib/celluloid/tasks/task_thread.rb +0 -53
  149. data/lib/celluloid/thread_handle.rb +0 -50
  150. data/lib/celluloid/uuid.rb +0 -38
  151. data/spec/celluloid/cpu_counter_spec.rb +0 -82
  152. data/spec/celluloid/fsm_spec.rb +0 -107
  153. data/spec/celluloid/internal_pool_spec.rb +0 -52
  154. data/spec/celluloid/links_spec.rb +0 -45
  155. data/spec/celluloid/logging/ring_buffer_spec.rb +0 -38
  156. data/spec/celluloid/notifications_spec.rb +0 -120
  157. data/spec/celluloid/pool_spec.rb +0 -92
  158. data/spec/celluloid/probe_spec.rb +0 -121
  159. data/spec/celluloid/properties_spec.rb +0 -42
  160. data/spec/celluloid/registry_spec.rb +0 -64
  161. data/spec/celluloid/stack_dump_spec.rb +0 -64
  162. data/spec/celluloid/supervision_group_spec.rb +0 -65
  163. data/spec/celluloid/supervisor_spec.rb +0 -103
  164. data/spec/celluloid/tasks/task_fiber_spec.rb +0 -5
  165. data/spec/celluloid/tasks/task_thread_spec.rb +0 -5
  166. data/spec/celluloid/thread_handle_spec.rb +0 -26
  167. data/spec/celluloid/uuid_spec.rb +0 -11
@@ -1,5 +1,5 @@
1
1
 
2
- require 'timers'
2
+ require "timers"
3
3
 
4
4
  module Celluloid
5
5
  # Actors are Celluloid's concurrency primitive. They're implemented as
@@ -12,37 +12,37 @@ module Celluloid
12
12
  class << self
13
13
  extend Forwardable
14
14
 
15
- def_delegators "Celluloid.actor_system", :[], :[]=, :delete, :registered, :clear_registry
15
+ def_delegators :"Celluloid.actor_system", :[], :[]=, :delete, :registered, :clear_registry
16
16
 
17
17
  # Obtain the current actor
18
18
  def current
19
19
  actor = Thread.current[:celluloid_actor]
20
- raise NotActorError, "not in actor scope" unless actor
20
+ fail NotActorError, "not in actor scope" unless actor
21
21
  actor.behavior_proxy
22
22
  end
23
23
 
24
24
  # Obtain the name of the current actor
25
25
  def registered_name
26
26
  actor = Thread.current[:celluloid_actor]
27
- raise NotActorError, "not in actor scope" unless actor
27
+ fail NotActorError, "not in actor scope" unless actor
28
28
  actor.name
29
29
  end
30
30
 
31
31
  # Invoke a method on the given actor via its mailbox
32
32
  def call(mailbox, meth, *args, &block)
33
- proxy = SyncProxy.new(mailbox, "UnknownClass")
33
+ proxy = Proxy::Sync.new(mailbox, "UnknownClass")
34
34
  proxy.method_missing(meth, *args, &block)
35
35
  end
36
36
 
37
37
  # Invoke a method asynchronously on an actor via its mailbox
38
38
  def async(mailbox, meth, *args, &block)
39
- proxy = AsyncProxy.new(mailbox, "UnknownClass")
39
+ proxy = Proxy::Async.new(mailbox, "UnknownClass")
40
40
  proxy.method_missing(meth, *args, &block)
41
41
  end
42
42
 
43
43
  # Call a method asynchronously and retrieve its value later
44
44
  def future(mailbox, meth, *args, &block)
45
- proxy = FutureProxy.new(mailbox, "UnknownClass")
45
+ proxy = Proxy::Future.new(mailbox, "UnknownClass")
46
46
  proxy.method_missing(meth, *args, &block)
47
47
  end
48
48
 
@@ -53,13 +53,13 @@ module Celluloid
53
53
 
54
54
  # Watch for exit events from another actor
55
55
  def monitor(actor)
56
- raise NotActorError, "can't link outside actor context" unless Celluloid.actor?
56
+ fail NotActorError, "can't link outside actor context" unless Celluloid.actor?
57
57
  Thread.current[:celluloid_actor].linking_request(actor, :link)
58
58
  end
59
59
 
60
60
  # Stop waiting for exit events from another actor
61
61
  def unmonitor(actor)
62
- raise NotActorError, "can't link outside actor context" unless Celluloid.actor?
62
+ fail NotActorError, "can't link outside actor context" unless Celluloid.actor?
63
63
  Thread.current[:celluloid_actor].linking_request(actor, :unlink)
64
64
  end
65
65
 
@@ -85,10 +85,12 @@ module Celluloid
85
85
  monitoring?(actor) && Thread.current[:celluloid_actor].links.include?(actor)
86
86
  end
87
87
 
88
- # Forcibly kill a given actor
89
- def kill(actor)
90
- actor.thread.kill
91
- actor.mailbox.shutdown if actor.mailbox.alive?
88
+ unless RUBY_PLATFORM == "java" || RUBY_ENGINE == "rbx"
89
+ # Forcibly kill a given actor
90
+ def kill(actor)
91
+ actor.thread.kill
92
+ actor.mailbox.shutdown if actor.mailbox.alive?
93
+ end
92
94
  end
93
95
 
94
96
  # Wait for an actor to terminate
@@ -109,12 +111,12 @@ module Celluloid
109
111
  @exit_handler = method(:default_exit_handler)
110
112
  @exclusive = options.fetch(:exclusive, false)
111
113
 
112
- @tasks = TaskSet.new
113
- @links = Links.new
114
- @signals = Signals.new
115
114
  @timers = Timers::Group.new
116
- @receivers = Receivers.new(@timers)
117
- @handlers = Handlers.new
115
+ @tasks = Internals::TaskSet.new
116
+ @links = Internals::Links.new
117
+ @handlers = Internals::Handlers.new
118
+ @receivers = Internals::Receivers.new(@timers)
119
+ @signals = Internals::Signals.new
118
120
  @running = false
119
121
  @name = nil
120
122
 
@@ -125,12 +127,12 @@ module Celluloid
125
127
 
126
128
  def start
127
129
  @running = true
128
- @thread = ThreadHandle.new(@actor_system, :actor) do
130
+ @thread = Internals::ThreadHandle.new(@actor_system, :actor) do
129
131
  setup_thread
130
132
  run
131
133
  end
132
134
 
133
- @proxy = ActorProxy.new(@thread, @mailbox)
135
+ @proxy = Proxy::Actor.new(@thread, @mailbox)
134
136
  Celluloid::Probe.actor_created(self) if $CELLULOID_MONITORING
135
137
  end
136
138
 
@@ -148,8 +150,8 @@ module Celluloid
148
150
  while @running
149
151
  begin
150
152
  @timers.wait do |interval|
151
- interval = 0 if interval and interval < 0
152
-
153
+ interval = 0 if interval && interval < 0
154
+
153
155
  if message = @mailbox.check(interval)
154
156
  handle_message(message)
155
157
 
@@ -158,6 +160,9 @@ module Celluloid
158
160
  end
159
161
  rescue MailboxShutdown
160
162
  @running = false
163
+ rescue MailboxDead
164
+ # TODO: not tests (but fails occasionally in tests)
165
+ @running = false
161
166
  end
162
167
  end
163
168
 
@@ -191,19 +196,16 @@ module Celluloid
191
196
 
192
197
  if message.instance_of? LinkingResponse
193
198
  Celluloid::Probe.actors_linked(self, receiver) if $CELLULOID_MONITORING
194
-
195
- # We're done!
196
199
  system_events.each { |ev| @mailbox << ev }
197
-
198
200
  return
199
201
  elsif message.is_a? SystemEvent
200
202
  # Queue up pending system events to be processed after we've successfully linked
201
203
  system_events << message
202
- else raise "Unexpected message type: #{message.class}. Expected LinkingResponse, NilClass, SystemEvent."
204
+ else fail "Unexpected message type: #{message.class}. Expected LinkingResponse, NilClass, SystemEvent."
203
205
  end
204
206
  end
205
207
 
206
- raise TimeoutError, "linking timeout of #{LINKING_TIMEOUT} seconds exceeded"
208
+ fail TimeoutError, "linking timeout of #{LINKING_TIMEOUT} seconds exceeded with receiver: #{receiver}"
207
209
  end
208
210
  end
209
211
 
@@ -223,9 +225,9 @@ module Celluloid
223
225
 
224
226
  # Receive an asynchronous message
225
227
  def receive(timeout = nil, &block)
226
- loop do
228
+ while true
227
229
  message = @receivers.receive(timeout, &block)
228
- break message unless message.is_a?(SystemEvent)
230
+ return message unless message.is_a?(SystemEvent)
229
231
 
230
232
  handle_system_event(message)
231
233
  end
@@ -279,7 +281,7 @@ module Celluloid
279
281
  def handle_message(message)
280
282
  unless @handlers.handle_message(message)
281
283
  unless @receivers.handle_message(message)
282
- Logger.debug "Discarded message (unhandled): #{message}" if $CELLULOID_DEBUG
284
+ Internals::Logger.debug "Discarded message (unhandled): #{message}" if $CELLULOID_DEBUG
283
285
  end
284
286
  end
285
287
  message
@@ -299,7 +301,7 @@ module Celluloid
299
301
  elsif event.instance_of? SignalConditionRequest
300
302
  event.call
301
303
  else
302
- Logger.debug "Discarded message (unhandled): #{message}" if $CELLULOID_DEBUG
304
+ Internals::Logger.debug "Discarded message (unhandled): #{message}" if $CELLULOID_DEBUG
303
305
  end
304
306
  end
305
307
 
@@ -311,16 +313,16 @@ module Celluloid
311
313
  end
312
314
 
313
315
  def default_exit_handler(event)
314
- raise event.reason if event.reason
316
+ fail event.reason if event.reason
315
317
  end
316
318
 
317
319
  # Handle any exceptions that occur within a running actor
318
320
  def handle_crash(exception)
319
321
  # TODO: add meta info
320
- Logger.crash("Actor crashed!", exception)
322
+ Internals::Logger.crash("Actor crashed!", exception)
321
323
  shutdown ExitEvent.new(behavior_proxy, exception)
322
324
  rescue => ex
323
- Logger.crash("ERROR HANDLER CRASHED!", ex)
325
+ Internals::Logger.crash("Actor#handle_crash CRASHED!", ex)
324
326
  end
325
327
 
326
328
  # Handle cleaning up this actor after it exits
@@ -337,26 +339,30 @@ module Celluloid
337
339
  Celluloid::Probe.actor_died(self) if $CELLULOID_MONITORING
338
340
  @mailbox.shutdown
339
341
  @links.each do |actor|
340
- if actor.mailbox.alive?
341
- actor.mailbox << exit_event
342
- end
342
+ actor.mailbox << exit_event if actor.mailbox.alive?
343
343
  end
344
344
 
345
- tasks.to_a.each(&:terminate)
345
+ tasks.to_a.each do |task|
346
+ begin
347
+ task.terminate
348
+ rescue DeadTaskError
349
+ # TODO: not tested (failed on Travis)
350
+ end
351
+ end
346
352
  rescue => ex
347
353
  # TODO: metadata
348
- Logger.crash("CLEANUP CRASHED!", ex)
354
+ Internals::Logger.crash("CLEANUP CRASHED!", ex)
349
355
  end
350
356
 
351
357
  # Run a method inside a task unless it's exclusive
352
358
  def task(task_type, meta = nil)
353
- @task_class.new(task_type, meta) {
359
+ @task_class.new(task_type, meta) do
354
360
  if @exclusive
355
361
  Celluloid.exclusive { yield }
356
362
  else
357
363
  yield
358
364
  end
359
- }.resume
365
+ end.resume
360
366
  end
361
367
  end
362
368
  end
@@ -1,19 +1,63 @@
1
1
  module Celluloid
2
+ extend Forwardable
3
+ def_delegators :actor_system, :[], :[]=
4
+
2
5
  class ActorSystem
3
6
  extend Forwardable
7
+ def_delegators :@registry, :[], :get, :[]=, :set, :delete
8
+
9
+ ROOT_SERVICES = [
10
+ {
11
+ as: :notifications_fanout,
12
+ type: Celluloid::Notifications::Fanout,
13
+ },
14
+ {
15
+ as: :incident_reporter,
16
+ type: Celluloid::IncidentReporter,
17
+ args: [STDERR],
18
+ },
19
+ {
20
+ as: :group_manager,
21
+ type: Celluloid::Group::Manager,
22
+ accessors: [:manager],
23
+ },
24
+ {
25
+ as: :public_services,
26
+ type: Celluloid::Supervision::Service::Public,
27
+ accessors: [:services],
28
+ supervise: [],
29
+ },
30
+ ]
31
+
32
+ attr_reader :registry, :group
33
+
34
+ module Error
35
+ class Uninitialized < StandardError; end
36
+ end
37
+
38
+ # the root of the supervisor tree is established at supervision/root
39
+
40
+ def root_services
41
+ @tree
42
+ end
43
+
44
+ def root_configuration
45
+ @root
46
+ end
4
47
 
5
48
  def initialize
6
- @internal_pool = InternalPool.new
7
- @registry = Registry.new
49
+ @tree = nil
50
+ @group = Celluloid.group_class.new
51
+ @registry = Internals::Registry.new
52
+ @root = ROOT_SERVICES
8
53
  end
9
- attr_reader :registry
10
54
 
11
55
  # Launch default services
12
- # FIXME: We should set up the supervision hierarchy here
13
56
  def start
14
57
  within do
15
- Celluloid::Notifications::Fanout.supervise_as :notifications_fanout
16
- Celluloid::IncidentReporter.supervise_as :default_incident_reporter, STDERR
58
+ @root = Supervision::Service::Root.define
59
+ @tree = root_configuration.deploy
60
+ # de root_services[:group_manager].manage! @group
17
61
  end
18
62
  true
19
63
  end
@@ -27,17 +71,19 @@ module Celluloid
27
71
  end
28
72
 
29
73
  def get_thread
30
- @internal_pool.get do
74
+ @group.get do
31
75
  Thread.current[:celluloid_actor_system] = self
32
76
  yield
33
77
  end
34
78
  end
35
79
 
36
80
  def stack_dump
37
- Celluloid::StackDump.new(@internal_pool)
81
+ Internals::Stack::Dump.new(@group)
38
82
  end
39
83
 
40
- def_delegators "@registry", :[], :get, :[]=, :set, :delete
84
+ def stack_summary
85
+ Internals::Stack::Summary.new(@group)
86
+ end
41
87
 
42
88
  def registered
43
89
  @registry.names
@@ -49,22 +95,29 @@ module Celluloid
49
95
 
50
96
  def running
51
97
  actors = []
52
- @internal_pool.each do |t|
98
+ @group.each do |t|
53
99
  next unless t.role == :actor
54
- actors << t.actor.behavior_proxy if t.actor && t.actor.respond_to?(:behavior_proxy)
100
+ actor = t.actor
101
+
102
+ # NOTE - these are in separate statements, since on JRuby t.actor may
103
+ # become nil befor .behavior_proxy() is called
104
+ next unless actor
105
+ next unless actor.respond_to?(:behavior_proxy)
106
+ proxy = actor.behavior_proxy
107
+ actors << proxy
55
108
  end
56
109
  actors
57
110
  end
58
111
 
59
112
  def running?
60
- @internal_pool.running?
113
+ @group.active?
61
114
  end
62
115
 
63
116
  # Shut down all running actors
64
117
  def shutdown
65
118
  actors = running
66
119
  Timeout.timeout(shutdown_timeout) do
67
- Logger.debug "Terminating #{actors.size} #{(actors.size > 1) ? 'actors' : 'actor'}..." if actors.size > 0
120
+ Internals::Logger.debug "Terminating #{actors.size} #{(actors.size > 1) ? 'actors' : 'actor'}..." if actors.size > 0
68
121
 
69
122
  # Actors cannot self-terminate, you must do it for them
70
123
  actors.each do |actor|
@@ -80,24 +133,24 @@ module Celluloid
80
133
  rescue DeadActorError
81
134
  end
82
135
  end
83
-
84
- @internal_pool.shutdown
85
136
  end
86
137
  rescue Timeout::Error
87
- Logger.error("Couldn't cleanly terminate all actors in #{shutdown_timeout} seconds!")
88
- actors.each do |actor|
89
- begin
90
- Actor.kill(actor)
91
- rescue DeadActorError, MailboxDead
138
+ Internals::Logger.error("Couldn't cleanly terminate all actors in #{shutdown_timeout} seconds!")
139
+ unless RUBY_PLATFORM == "java" || RUBY_ENGINE == "rbx"
140
+ actors.each do |actor|
141
+ begin
142
+ Actor.kill(actor)
143
+ rescue DeadActorError, MailboxDead
144
+ end
92
145
  end
93
146
  end
94
147
  ensure
95
- @internal_pool.kill
148
+ @group.shutdown
96
149
  clear_registry
97
150
  end
98
151
 
99
152
  def assert_inactive
100
- @internal_pool.assert_inactive
153
+ @group.assert_inactive
101
154
  end
102
155
 
103
156
  def shutdown_timeout
@@ -1,3 +1,3 @@
1
- require 'celluloid'
1
+ require "celluloid"
2
2
 
3
3
  Celluloid.start
@@ -0,0 +1,2 @@
1
+ $CELLULOID_BACKPORTED = true
2
+ require "celluloid/autostart"
@@ -0,0 +1,16 @@
1
+ module Celluloid
2
+ class Call
3
+ # Asynchronous calls don't wait for a response
4
+ class Async < Call
5
+ def dispatch(obj)
6
+ Internals::CallChain.current_id = Celluloid.uuid
7
+ super(obj)
8
+ rescue AbortError => ex
9
+ # Swallow aborted async calls, as they indicate the sender made a mistake
10
+ Internals::Logger.debug("#{obj.class}: async call `#{@method}` aborted!\n#{Internals::Logger.format_exception(ex.cause)}")
11
+ ensure
12
+ Internals::CallChain.current_id = nil
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ module Celluloid
2
+ class Call
3
+ class Block
4
+ def initialize(block_proxy, sender, arguments, task = Thread.current[:celluloid_task])
5
+ @block_proxy = block_proxy
6
+ @sender = sender
7
+ @arguments = arguments
8
+ @task = task
9
+ end
10
+ attr_reader :task
11
+
12
+ def call
13
+ @block_proxy.call
14
+ end
15
+
16
+ def dispatch
17
+ response = @block_proxy.block.call(*@arguments)
18
+ @sender << Internals::Response::Block.new(self, response)
19
+ end
20
+ end
21
+ end
22
+ end