celluloid 0.18.0.pre → 0.18.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 (179) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES.md +114 -39
  3. data/CONDUCT.md +13 -0
  4. data/CONTRIBUTING.md +39 -0
  5. data/README.md +59 -55
  6. data/architecture.md +120 -0
  7. data/examples/basic_usage.rb +1 -1
  8. data/examples/configurations.rb +78 -0
  9. data/examples/futures.rb +1 -1
  10. data/examples/ring.rb +5 -4
  11. data/examples/simple_pmap.rb +1 -1
  12. data/examples/stack.rb +2 -2
  13. data/examples/supervisors_and_registry.rb +82 -0
  14. data/examples/timers.rb +1 -1
  15. data/lib/celluloid.rb +72 -47
  16. data/lib/celluloid/actor.rb +27 -17
  17. data/lib/celluloid/actor/system.rb +13 -29
  18. data/lib/celluloid/autostart.rb +5 -5
  19. data/lib/celluloid/backported.rb +6 -2
  20. data/lib/celluloid/call/async.rb +2 -0
  21. data/lib/celluloid/call/sync.rb +10 -3
  22. data/lib/celluloid/calls.rb +5 -12
  23. data/lib/celluloid/cell.rb +5 -9
  24. data/lib/celluloid/condition.rb +3 -3
  25. data/lib/celluloid/core_ext.rb +0 -2
  26. data/lib/celluloid/current.rb +3 -1
  27. data/lib/celluloid/debug.rb +3 -0
  28. data/lib/celluloid/exceptions.rb +2 -2
  29. data/lib/celluloid/future.rb +7 -9
  30. data/lib/celluloid/group.rb +12 -8
  31. data/lib/celluloid/group/pool.rb +1 -3
  32. data/lib/celluloid/group/spawner.rb +2 -6
  33. data/lib/celluloid/internals/call_chain.rb +15 -0
  34. data/lib/celluloid/internals/cpu_counter.rb +62 -0
  35. data/lib/celluloid/internals/handlers.rb +42 -0
  36. data/lib/celluloid/internals/links.rb +38 -0
  37. data/lib/celluloid/internals/logger.rb +104 -0
  38. data/lib/celluloid/internals/method.rb +34 -0
  39. data/lib/celluloid/internals/properties.rb +32 -0
  40. data/lib/celluloid/internals/receivers.rb +64 -0
  41. data/lib/celluloid/internals/registry.rb +102 -0
  42. data/lib/celluloid/internals/responses.rb +46 -0
  43. data/lib/celluloid/internals/signals.rb +24 -0
  44. data/lib/celluloid/internals/stack.rb +74 -0
  45. data/lib/celluloid/internals/stack/dump.rb +12 -0
  46. data/lib/celluloid/internals/stack/states.rb +72 -0
  47. data/lib/celluloid/internals/stack/summary.rb +12 -0
  48. data/lib/celluloid/internals/task_set.rb +51 -0
  49. data/lib/celluloid/internals/thread_handle.rb +52 -0
  50. data/lib/celluloid/internals/uuid.rb +40 -0
  51. data/lib/celluloid/logging/incident.rb +21 -0
  52. data/lib/celluloid/logging/incident_logger.rb +147 -0
  53. data/lib/celluloid/logging/incident_reporter.rb +49 -0
  54. data/lib/celluloid/logging/log_event.rb +20 -0
  55. data/lib/celluloid/logging/ring_buffer.rb +64 -0
  56. data/lib/celluloid/mailbox.rb +22 -9
  57. data/lib/celluloid/mailbox/evented.rb +13 -5
  58. data/lib/celluloid/managed.rb +6 -3
  59. data/lib/celluloid/notifications.rb +95 -0
  60. data/lib/celluloid/pool.rb +6 -0
  61. data/lib/celluloid/probe.rb +81 -0
  62. data/lib/celluloid/proxy/abstract.rb +9 -9
  63. data/lib/celluloid/proxy/async.rb +1 -1
  64. data/lib/celluloid/proxy/block.rb +2 -2
  65. data/lib/celluloid/proxy/cell.rb +1 -1
  66. data/lib/celluloid/proxy/future.rb +2 -4
  67. data/lib/celluloid/proxy/sync.rb +1 -3
  68. data/lib/celluloid/rspec.rb +22 -33
  69. data/lib/celluloid/supervision.rb +17 -0
  70. data/lib/celluloid/supervision/configuration.rb +169 -0
  71. data/lib/celluloid/supervision/configuration/injections.rb +8 -0
  72. data/lib/celluloid/supervision/configuration/instance.rb +113 -0
  73. data/lib/celluloid/supervision/constants.rb +123 -0
  74. data/lib/celluloid/supervision/container.rb +144 -0
  75. data/lib/celluloid/supervision/container/behavior.rb +89 -0
  76. data/lib/celluloid/supervision/container/behavior/pool.rb +71 -0
  77. data/lib/celluloid/supervision/container/behavior/tree.rb +23 -0
  78. data/lib/celluloid/supervision/container/injections.rb +8 -0
  79. data/lib/celluloid/supervision/container/instance.rb +116 -0
  80. data/lib/celluloid/supervision/container/pool.rb +210 -0
  81. data/{culture/rubocop/perf.yml → lib/celluloid/supervision/container/tree.rb} +0 -0
  82. data/lib/celluloid/supervision/deprecate.rb +9 -0
  83. data/lib/celluloid/supervision/deprecate/supervise.rb +105 -0
  84. data/lib/celluloid/supervision/deprecate/validation.rb +54 -0
  85. data/lib/celluloid/supervision/service.rb +27 -0
  86. data/lib/celluloid/supervision/supervise.rb +34 -0
  87. data/lib/celluloid/supervision/validation.rb +40 -0
  88. data/lib/celluloid/supervision/version.rb +5 -0
  89. data/lib/celluloid/system_events.rb +11 -6
  90. data/lib/celluloid/task.rb +25 -12
  91. data/lib/celluloid/task/fibered.rb +2 -0
  92. data/lib/celluloid/task/threaded.rb +3 -3
  93. data/lib/celluloid/test.rb +5 -2
  94. data/lib/celluloid/thread.rb +0 -2
  95. data/lib/celluloid/version.rb +1 -1
  96. data/spec/celluloid/block_spec.rb +29 -32
  97. data/spec/celluloid/calls_spec.rb +5 -15
  98. data/spec/celluloid/future_spec.rb +2 -2
  99. data/spec/celluloid/internals/cpu_counter_spec.rb +129 -0
  100. data/spec/celluloid/internals/links_spec.rb +43 -0
  101. data/spec/celluloid/internals/properties_spec.rb +40 -0
  102. data/spec/celluloid/internals/registry_spec.rb +62 -0
  103. data/spec/celluloid/internals/stack/dump_spec.rb +4 -0
  104. data/spec/celluloid/internals/stack/summary_spec.rb +4 -0
  105. data/spec/celluloid/internals/thread_handle_spec.rb +60 -0
  106. data/spec/celluloid/internals/uuid_spec.rb +9 -0
  107. data/spec/celluloid/logging/ring_buffer_spec.rb +36 -0
  108. data/spec/celluloid/mailbox/evented_spec.rb +11 -22
  109. data/spec/celluloid/misc/leak_spec.rb +3 -4
  110. data/spec/celluloid/notifications_spec.rb +140 -0
  111. data/spec/celluloid/probe_spec.rb +102 -0
  112. data/spec/celluloid/proxy_spec.rb +30 -30
  113. data/spec/celluloid/supervision/behavior_spec.rb +74 -0
  114. data/spec/celluloid/supervision/configuration_spec.rb +181 -0
  115. data/spec/celluloid/supervision/container_spec.rb +72 -0
  116. data/spec/celluloid/supervision/instance_spec.rb +13 -0
  117. data/spec/celluloid/supervision/root_spec.rb +28 -0
  118. data/spec/celluloid/supervision/supervisor_spec.rb +93 -0
  119. data/spec/celluloid/task/fibered_spec.rb +1 -3
  120. data/spec/celluloid/task/threaded_spec.rb +1 -3
  121. data/spec/shared/actor_examples.rb +58 -33
  122. data/spec/shared/group_examples.rb +2 -2
  123. data/spec/shared/mailbox_examples.rb +1 -1
  124. data/spec/shared/stack_examples.rb +87 -0
  125. data/spec/shared/task_examples.rb +2 -3
  126. data/spec/spec_helper.rb +2 -4
  127. data/spec/support/configure_rspec.rb +2 -3
  128. data/spec/support/coverage.rb +2 -4
  129. data/spec/support/crash_checking.rb +2 -2
  130. data/spec/support/examples/actor_class.rb +3 -8
  131. data/spec/support/examples/call_class.rb +2 -2
  132. data/spec/support/examples/container_class.rb +35 -0
  133. data/spec/support/examples/evented_mailbox_class.rb +1 -2
  134. data/spec/support/examples/stack_classes.rb +58 -0
  135. data/spec/support/examples/stack_methods.rb +23 -0
  136. data/spec/support/examples/subordinate_class.rb +19 -0
  137. data/spec/support/logging.rb +2 -34
  138. data/spec/support/loose_threads.rb +3 -16
  139. data/spec/support/reset_class_variables.rb +5 -1
  140. data/spec/support/stubbing.rb +1 -1
  141. metadata +91 -316
  142. data/culture/CONDUCT.md +0 -38
  143. data/culture/GSoC/1010-why_we_will_participate.md +0 -17
  144. data/culture/GSoC/1020-how_mentors_stay_engaged.md +0 -7
  145. data/culture/GSoC/1030-keeping_students_on_schedule.md +0 -9
  146. data/culture/GSoC/1040-getting_students_involved.md +0 -5
  147. data/culture/GSoC/1050-student_involvement_after.md +0 -5
  148. data/culture/GSoC/README.md +0 -16
  149. data/culture/Gemfile +0 -9
  150. data/culture/LICENSE.txt +0 -22
  151. data/culture/README.md +0 -22
  152. data/culture/Rakefile +0 -5
  153. data/culture/SYNC.md +0 -70
  154. data/culture/celluloid-culture.gemspec +0 -18
  155. data/culture/gems/README.md +0 -39
  156. data/culture/gems/dependencies.yml +0 -93
  157. data/culture/gems/loader.rb +0 -101
  158. data/culture/rubocop/README.md +0 -38
  159. data/culture/rubocop/lint.yml +0 -8
  160. data/culture/rubocop/metrics.yml +0 -15
  161. data/culture/rubocop/rubocop.yml +0 -5
  162. data/culture/rubocop/style.yml +0 -61
  163. data/culture/spec/gems_spec.rb +0 -2
  164. data/culture/spec/spec_helper.rb +0 -0
  165. data/culture/spec/sync_spec.rb +0 -2
  166. data/culture/sync.rb +0 -56
  167. data/culture/tasks/rspec.rake +0 -5
  168. data/culture/tasks/rubocop.rake +0 -2
  169. data/lib/celluloid/actor/manager.rb +0 -7
  170. data/lib/celluloid/deprecate.rb +0 -34
  171. data/lib/celluloid/fiber.rb +0 -32
  172. data/lib/celluloid/notices.rb +0 -15
  173. data/spec/deprecate/actor_system_spec.rb +0 -72
  174. data/spec/deprecate/block_spec.rb +0 -52
  175. data/spec/deprecate/calls_spec.rb +0 -39
  176. data/spec/deprecate/evented_mailbox_spec.rb +0 -34
  177. data/spec/deprecate/future_spec.rb +0 -32
  178. data/spec/deprecate/internal_pool_spec.rb +0 -4
  179. data/spec/support/env.rb +0 -21
@@ -16,14 +16,14 @@ module Celluloid
16
16
  # Obtain the current actor
17
17
  def current
18
18
  actor = Thread.current[:celluloid_actor]
19
- fail NotActorError, "not in actor scope" unless actor
19
+ raise NotActorError, "not in actor scope" unless actor
20
20
  actor.behavior_proxy
21
21
  end
22
22
 
23
23
  # Obtain the name of the current actor
24
24
  def registered_name
25
25
  actor = Thread.current[:celluloid_actor]
26
- fail NotActorError, "not in actor scope" unless actor
26
+ raise NotActorError, "not in actor scope" unless actor
27
27
  actor.name
28
28
  end
29
29
 
@@ -52,13 +52,13 @@ module Celluloid
52
52
 
53
53
  # Watch for exit events from another actor
54
54
  def monitor(actor)
55
- fail NotActorError, "can't link outside actor context" unless Celluloid.actor?
55
+ raise NotActorError, "can't link outside actor context" unless Celluloid.actor?
56
56
  Thread.current[:celluloid_actor].linking_request(actor, :link)
57
57
  end
58
58
 
59
59
  # Stop waiting for exit events from another actor
60
60
  def unmonitor(actor)
61
- fail NotActorError, "can't link outside actor context" unless Celluloid.actor?
61
+ raise NotActorError, "can't link outside actor context" unless Celluloid.actor?
62
62
  Thread.current[:celluloid_actor].linking_request(actor, :unlink)
63
63
  end
64
64
 
@@ -132,8 +132,11 @@ module Celluloid
132
132
  end
133
133
 
134
134
  @proxy = Proxy::Actor.new(@mailbox, @thread)
135
+
136
+ # !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
137
+ # rubocop:disable Style/GlobalVars
135
138
  Celluloid::Probe.actor_created(self) if $CELLULOID_MONITORING
136
- Celluloid::Actor::Manager.actor_created(self) if $CELLULOID_MANAGED
139
+ # rubocop:enable Style/GlobalVars
137
140
  end
138
141
 
139
142
  def behavior_proxy
@@ -187,25 +190,28 @@ module Celluloid
187
190
  begin
188
191
  message = @mailbox.receive(remaining) do |msg|
189
192
  msg.is_a?(LinkingResponse) &&
190
- msg.actor.mailbox.address == receiver.mailbox.address &&
191
- msg.type == type
193
+ msg.actor.mailbox.address == receiver.mailbox.address &&
194
+ msg.type == type
192
195
  end
193
196
  rescue TaskTimeout
194
197
  next # IO reactor did something, no message in queue yet.
195
198
  end
196
199
 
197
200
  if message.instance_of? LinkingResponse
201
+ # !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
202
+ # rubocop:disable Style/GlobalVars
198
203
  Celluloid::Probe.actors_linked(self, receiver) if $CELLULOID_MONITORING
204
+ # rubocop:enable Style/GlobalVars
199
205
  system_events.each { |ev| @mailbox << ev }
200
206
  return
201
207
  elsif message.is_a? SystemEvent
202
208
  # Queue up pending system events to be processed after we've successfully linked
203
209
  system_events << message
204
- else fail "Unexpected message type: #{message.class}. Expected LinkingResponse, NilClass, SystemEvent."
210
+ else raise "Unexpected message type: #{message.class}. Expected LinkingResponse, NilClass, SystemEvent."
205
211
  end
206
212
  end
207
213
 
208
- fail TaskTimeout, "linking timeout of #{LINKING_TIMEOUT} seconds exceeded with receiver: #{receiver}"
214
+ raise TaskTimeout, "linking timeout of #{LINKING_TIMEOUT} seconds exceeded with receiver: #{receiver}"
209
215
  end
210
216
  end
211
217
 
@@ -218,7 +224,7 @@ module Celluloid
218
224
  def wait(name)
219
225
  @signals.wait name
220
226
  end
221
-
227
+
222
228
  # Register a new handler for a given pattern
223
229
  def handle(*patterns, &block)
224
230
  @handlers.handle(*patterns, &block)
@@ -226,7 +232,7 @@ module Celluloid
226
232
 
227
233
  # Receive an asynchronous message
228
234
  def receive(timeout = nil, &block)
229
- while true
235
+ loop do
230
236
  message = @receivers.receive(timeout, &block)
231
237
  return message unless message.is_a?(SystemEvent)
232
238
 
@@ -280,16 +286,16 @@ module Celluloid
280
286
 
281
287
  # Handle standard low-priority messages
282
288
  def handle_message(message)
283
- unless @handlers.handle_message(message)
284
- unless @receivers.handle_message(message)
285
- Internals::Logger.debug "Discarded message (unhandled): #{message}" if $CELLULOID_DEBUG
286
- end
287
- end
289
+ # !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
290
+ # rubocop:disable Metrics/LineLength, Style/GlobalVars
291
+ Internals::Logger.debug "Discarded message (unhandled): #{message}" if !@handlers.handle_message(message) && !@receivers.handle_message(message) && $CELLULOID_DEBUG
292
+ # rubocop:enable Metrics/LineLength, Style/GlobalVars
293
+
288
294
  message
289
295
  end
290
296
 
291
297
  def default_exit_handler(event)
292
- fail event.reason if event.reason
298
+ raise event.reason if event.reason
293
299
  end
294
300
 
295
301
  # Handle any exceptions that occur within a running actor
@@ -312,7 +318,11 @@ module Celluloid
312
318
 
313
319
  # Clean up after this actor
314
320
  def cleanup(exit_event)
321
+ # !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
322
+ # rubocop:disable Style/GlobalVars
315
323
  Celluloid::Probe.actor_died(self) if $CELLULOID_MONITORING
324
+ # rubocop:enable Style/GlobalVars
325
+
316
326
  @mailbox.shutdown
317
327
  @links.each do |actor|
318
328
  actor.mailbox << exit_event if actor.mailbox.alive?
@@ -7,33 +7,18 @@ module Celluloid
7
7
  extend Forwardable
8
8
  def_delegators :@registry, :[], :get, :[]=, :set, :delete
9
9
 
10
- ROOT_SERVICES = begin
11
- root_services = [
12
- {
13
- as: :notifications_fanout,
14
- type: Celluloid::Notifications::Fanout,
15
- },
16
- {
17
- as: :incident_reporter,
18
- type: Celluloid::IncidentReporter,
19
- args: [STDERR],
20
- },
21
- {
22
- as: :public_services,
23
- type: Celluloid::Supervision::Service::Public,
24
- accessors: [:services],
25
- supervise: [],
26
- },
27
- ]
28
- if $CELLULOID_MANAGED
29
- root_services << {
30
- as: :actor_manager,
31
- type: Celluloid::Actor::Manager,
32
- accessors: [:manager],
33
- }
34
- end
35
- root_services
36
- end
10
+ ROOT_SERVICES = [
11
+ {
12
+ as: :notifications_fanout,
13
+ type: Celluloid::Notifications::Fanout
14
+ },
15
+ {
16
+ as: :public_services,
17
+ type: Celluloid::Supervision::Service::Public,
18
+ accessors: [:services],
19
+ supervise: []
20
+ }
21
+ ].freeze
37
22
 
38
23
  attr_reader :registry, :group
39
24
 
@@ -59,7 +44,6 @@ module Celluloid
59
44
  within do
60
45
  @root = Supervision::Service::Root.define
61
46
  @tree = root_configuration.deploy
62
- # de root_services[:group_manager].manage! @group
63
47
  end
64
48
  true
65
49
  end
@@ -119,7 +103,7 @@ module Celluloid
119
103
  def shutdown
120
104
  actors = running
121
105
  Timeout.timeout(shutdown_timeout) do
122
- Internals::Logger.debug "Terminating #{actors.size} #{(actors.size > 1) ? 'actors' : 'actor'}..." if actors.size > 0
106
+ Internals::Logger.debug "Terminating #{actors.size} #{actors.size > 1 ? 'actors' : 'actor'}..." unless actors.empty?
123
107
 
124
108
  # Actors cannot self-terminate, you must do it for them
125
109
  actors.each do |actor|
@@ -1,8 +1,8 @@
1
1
  require "celluloid"
2
2
 
3
- Celluloid.start
3
+ Celluloid.boot
4
4
 
5
- unless defined?($CELLULOID_TEST) && $CELLULOID_TEST
6
- Celluloid.register_shutdown
7
- Celluloid.init
8
- end
5
+ # !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
6
+ # rubocop:disable Style/GlobalVars
7
+ Celluloid.register_shutdown unless defined?($CELLULOID_TEST) && $CELLULOID_TEST
8
+ # rubocop:enable Style/GlobalVars
@@ -1,2 +1,6 @@
1
- $CELLULOID_BACKPORTED = true
2
- require "celluloid/autostart"
1
+ raise NotImplementedError, <<-MSG.strip.gsub(/\s+/, " ")
2
+ Celluloid 0.18 no-longer supports the "backported" API.
3
+ Please switch to using: `require 'celluloid'`
4
+ For more information, see:
5
+ https://github.com/celluloid/celluloid/wiki/0.18-API-changes
6
+ MSG
@@ -7,7 +7,9 @@ module Celluloid
7
7
  super(obj)
8
8
  rescue AbortError => ex
9
9
  # Swallow aborted async calls, as they indicate the sender made a mistake
10
+ # rubocop:disable Metrics/LineLength
10
11
  Internals::Logger.debug("#{obj.class}: async call `#{@method}` aborted!\n#{Internals::Logger.format_exception(ex.cause)}")
12
+ # rubocop:enable Metrics/LineLength
11
13
  ensure
12
14
  Internals::CallChain.current_id = nil
13
15
  end
@@ -4,7 +4,14 @@ module Celluloid
4
4
  class Sync < Call
5
5
  attr_reader :sender, :task, :chain_id
6
6
 
7
- def initialize(sender, method, arguments = [], block = nil, task = Thread.current[:celluloid_task], chain_id = Internals::CallChain.current_id)
7
+ def initialize(
8
+ sender,
9
+ method,
10
+ arguments = [],
11
+ block = nil,
12
+ task = Thread.current[:celluloid_task],
13
+ chain_id = Internals::CallChain.current_id
14
+ )
8
15
  super(method, arguments, block)
9
16
  @sender = sender
10
17
  @task = task
@@ -29,7 +36,7 @@ module Celluloid
29
36
  end
30
37
 
31
38
  def cleanup
32
- exception = DeadActorError.new("attempted to call a dead actor: #{self.method}")
39
+ exception = DeadActorError.new("attempted to call a dead actor: #{method}")
33
40
  respond Internals::Response::Error.new(self, exception)
34
41
  end
35
42
 
@@ -46,7 +53,7 @@ module Celluloid
46
53
  end
47
54
 
48
55
  def wait
49
- while true
56
+ loop do
50
57
  message = Celluloid.mailbox.receive do |msg|
51
58
  msg.respond_to?(:call) && msg.call == self
52
59
  end
@@ -10,7 +10,7 @@ module Celluloid
10
10
  if block
11
11
  if Celluloid.exclusive?
12
12
  # FIXME: nicer exception
13
- fail "Cannot execute blocks on sender in exclusive mode"
13
+ raise "Cannot execute blocks on sender in exclusive mode"
14
14
  end
15
15
  @block = Proxy::Block.new(Celluloid.mailbox, self, block)
16
16
  else
@@ -24,14 +24,7 @@ module Celluloid
24
24
 
25
25
  def dispatch(obj)
26
26
  check(obj)
27
- _b = @block && @block.to_proc
28
- obj.public_send(@method, *@arguments, &_b)
29
- # rescue Celluloid::TaskTimeout => ex
30
- # raise ex unless ( @retry += 1 ) <= RETRY_CALL_LIMIT
31
- # puts "retrying"
32
- # Internals::Logger.warn("TaskTimeout at Call dispatch. Retrying in #{RETRY_CALL_WAIT} seconds. ( Attempt #{@retry} of #{RETRY_CALL_LIMIT} )")
33
- # sleep RETRY_CALL_WAIT
34
- # retry
27
+ obj.public_send(@method, *@arguments, &(@block && @block.to_proc))
35
28
  end
36
29
 
37
30
  def check(obj)
@@ -48,18 +41,18 @@ module Celluloid
48
41
  if @arguments.size != arity
49
42
  e = ArgumentError.new("wrong number of arguments (#{@arguments.size} for #{arity})")
50
43
  e.set_backtrace(caller << "#{meth.source_location.join(':')}: in `#{meth.name}`")
51
- fail e
44
+ raise e
52
45
  end
53
46
  elsif arity < -1
54
47
  mandatory_args = -arity - 1
55
48
  if arguments.size < mandatory_args
56
49
  e = ArgumentError.new("wrong number of arguments (#{@arguments.size} for #{mandatory_args}+)")
57
50
  e.set_backtrace(caller << "#{meth.source_location.join(':')}: in `#{meth.name}`")
58
- fail e
51
+ raise e
59
52
  end
60
53
  end
61
54
  rescue => ex
62
- raise AbortError.new(ex)
55
+ raise AbortError, ex
63
56
  end
64
57
  end
65
58
  end
@@ -36,9 +36,7 @@ module Celluloid
36
36
  @actor.handle(Call::Block) do |message|
37
37
  task(:invoke_block) { message.dispatch }
38
38
  end
39
- @actor.handle(Internals::Response::Block, Internals::Response) do |message|
40
- message.dispatch
41
- end
39
+ @actor.handle(Internals::Response::Block, Internals::Response, &:dispatch)
42
40
 
43
41
  @actor.start
44
42
  @proxy = (options[:proxy_class] || Proxy::Cell).new(@actor.mailbox, @actor.proxy, @subject.class.to_s)
@@ -57,18 +55,16 @@ module Celluloid
57
55
  meth = call.method
58
56
  meth = call.arguments.first if meth == :__send__
59
57
  if @receiver_block_executions && meth
60
- if @receiver_block_executions.include?(meth.to_sym)
61
- call.execute_block_on_receiver
62
- end
58
+ call.execute_block_on_receiver if @receiver_block_executions.include?(meth.to_sym)
63
59
  end
64
60
 
65
- task(:call, meth, {call: call, subject: @subject},
61
+ task(:call, meth, { call: call, subject: @subject },
66
62
  dangerous_suspend: meth == :initialize, &Cell.dispatch)
67
63
  end
68
64
 
69
65
  def task(task_type, method_name = nil, subject = nil, meta = nil, &_block)
70
66
  meta ||= {}
71
- meta.merge!(method_name: method_name)
67
+ meta[:method_name] = method_name
72
68
  @actor.task(task_type, meta) do
73
69
  if @exclusive_methods && method_name && @exclusive_methods.include?(method_name.to_sym)
74
70
  Celluloid.exclusive { yield subject }
@@ -94,7 +90,7 @@ module Celluloid
94
90
  def shutdown
95
91
  return unless @finalizer && @subject.respond_to?(@finalizer, true)
96
92
 
97
- task(:finalizer, @finalizer, {call: @finalizer, subject: @subject},
93
+ task(:finalizer, @finalizer, { call: @finalizer, subject: @subject },
98
94
  dangerous_suspend: true, &Cell.shutdown)
99
95
  end
100
96
  end
@@ -34,7 +34,7 @@ module Celluloid
34
34
 
35
35
  # Wait for the given signal and return the associated value
36
36
  def wait(timeout = nil)
37
- fail ConditionError, "cannot wait for signals while exclusive" if Celluloid.exclusive?
37
+ raise ConditionError, "cannot wait for signals while exclusive" if Celluloid.exclusive?
38
38
 
39
39
  if actor = Thread.current[:celluloid_actor]
40
40
  task = Task.current
@@ -57,7 +57,7 @@ module Celluloid
57
57
 
58
58
  result = Celluloid.suspend :condwait, waiter
59
59
  timer.cancel if timer
60
- fail result if result.is_a?(ConditionError)
60
+ raise result if result.is_a?(ConditionError)
61
61
  return yield(result) if block_given?
62
62
  result
63
63
  end
@@ -83,6 +83,6 @@ module Celluloid
83
83
  end
84
84
  end
85
85
 
86
- alias_method :inspect, :to_s
86
+ alias inspect to_s
87
87
  end
88
88
  end
@@ -1,5 +1,3 @@
1
- require "celluloid/fiber"
2
-
3
1
  class Thread
4
2
  attr_accessor :uuid_counter, :uuid_limit
5
3
 
@@ -1,2 +1,4 @@
1
- $CELLULOID_BACKPORTED = false
1
+ # Legacy support for the prescribed 0.17 API
2
+ # TODO: remove this in a future release
3
+
2
4
  require "celluloid"
@@ -1 +1,4 @@
1
+ # !!! DO NOT INTRODUCE ADDITIONAL GLOBAL VARIABLES !!!
2
+ # rubocop:disable Style/GlobalVars
1
3
  $CELLULOID_DEBUG = true
4
+ # rubocop:enable Style/GlobalVars
@@ -1,6 +1,6 @@
1
1
  module Celluloid
2
2
  class Error < StandardError; end
3
- class Interruption < Exception; end
3
+ class Interruption < RuntimeError; end
4
4
  class TimedOut < Celluloid::Interruption; end # Distinguished from `Timeout`
5
5
  class StillActive < Celluloid::Error; end
6
6
  class NotActive < Celluloid::Error; end
@@ -9,7 +9,7 @@ module Celluloid
9
9
  class NotTaskError < Celluloid::Error; end # Asked to do task-related things outside a task
10
10
  class DeadTaskError < Celluloid::Error; end # Trying to resume a dead task
11
11
  class TaskTerminated < Celluloid::Interruption; end # Kill a running task after terminate
12
- class TaskTimeout < Celluloid::TimedOut; end # A timeout occured before the given request could complete
12
+ class TaskTimeout < Celluloid::TimedOut; end # A timeout occurred before the given request could complete
13
13
  class ConditionError < Celluloid::Error; end
14
14
  class AbortError < Celluloid::Error # The sender made an error, not the current actor
15
15
  attr_reader :cause
@@ -1,5 +1,3 @@
1
- require "thread"
2
-
3
1
  module Celluloid
4
2
  # Celluloid::Future objects allow methods and blocks to run in the
5
3
  # background, their values requested later
@@ -50,7 +48,7 @@ module Celluloid
50
48
  # Execute the given method in future context
51
49
  def execute(receiver, method, args, block)
52
50
  @mutex.synchronize do
53
- fail "already calling" if @call
51
+ raise "already calling" if @call
54
52
  @call = Call::Sync.new(self, method, args, block)
55
53
  end
56
54
 
@@ -93,12 +91,12 @@ module Celluloid
93
91
  end
94
92
 
95
93
  if result
96
- (result.respond_to?(:value)) ? result.value : result
94
+ result.respond_to?(:value) ? result.value : result
97
95
  else
98
- fail TimedOut, "Timed out"
96
+ raise TimedOut, "Timed out"
99
97
  end
100
98
  end
101
- alias_method :call, :value
99
+ alias call value
102
100
 
103
101
  # Signal this future with the given result value
104
102
  def signal(value)
@@ -106,7 +104,7 @@ module Celluloid
106
104
  result = Result.new(value, self)
107
105
 
108
106
  @mutex.synchronize do
109
- fail "the future has already happened!" if @ready
107
+ raise "the future has already happened!" if @ready
110
108
 
111
109
  if @forwards
112
110
  @forwards.is_a?(Array) ? @forwards.each { |f| f << result } : @forwards << result
@@ -116,7 +114,7 @@ module Celluloid
116
114
  @ready = true
117
115
  end
118
116
  end
119
- alias_method :<<, :signal
117
+ alias << signal
120
118
 
121
119
  def cancel(error)
122
120
  response = Internals::Response::Error.new(@call, error)
@@ -127,7 +125,7 @@ module Celluloid
127
125
  end
128
126
 
129
127
  # Inspect this Celluloid::Future
130
- alias_method :inspect, :to_s
128
+ alias inspect to_s
131
129
 
132
130
  # Wrapper for result values to distinguish them in mailboxes
133
131
  class Result