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
@@ -0,0 +1,70 @@
1
+ module Celluloid
2
+ class Call
3
+ # Synchronous calls wait for a response
4
+ class Sync < Call
5
+ attr_reader :sender, :task, :chain_id
6
+
7
+ def initialize(sender, method, arguments = [], block = nil, task = Thread.current[:celluloid_task], chain_id = Internals::CallChain.current_id)
8
+ super(method, arguments, block)
9
+ @sender = sender
10
+ @task = task
11
+ @chain_id = chain_id || Celluloid.uuid
12
+ end
13
+
14
+ def dispatch(obj)
15
+ Internals::CallChain.current_id = @chain_id
16
+ result = super(obj)
17
+ respond Internals::Response::Success.new(self, result)
18
+ rescue Exception => ex
19
+ # Exceptions that occur during synchronous calls are reraised in the
20
+ # context of the sender
21
+ respond Internals::Response::Error.new(self, ex)
22
+
23
+ # Aborting indicates a protocol error on the part of the sender
24
+ # It should crash the sender, but the exception isn't reraised
25
+ # Otherwise, it's a bug in this actor and should be reraised
26
+ raise unless ex.is_a?(AbortError)
27
+ ensure
28
+ Internals::CallChain.current_id = nil
29
+ end
30
+
31
+ def cleanup
32
+ exception = DeadActorError.new("attempted to call a dead actor")
33
+ respond Internals::Response::Error.new(self, exception)
34
+ end
35
+
36
+ def respond(message)
37
+ @sender << message
38
+ end
39
+
40
+ def response
41
+ Celluloid.suspend(:callwait, self)
42
+ end
43
+
44
+ def value
45
+ response.value
46
+ end
47
+
48
+ def wait
49
+ while true
50
+ message = Celluloid.mailbox.receive do |msg|
51
+ msg.respond_to?(:call) && msg.call == self
52
+ end
53
+
54
+ if message.is_a?(SystemEvent)
55
+ Thread.current[:celluloid_actor].handle_system_event(message)
56
+ else
57
+ # FIXME: add check for receiver block execution
58
+ if message.respond_to?(:value)
59
+ # FIXME: disable block execution if on :sender and (exclusive or outside of task)
60
+ # probably now in Call
61
+ return message
62
+ else
63
+ message.dispatch
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -4,13 +4,15 @@ module Celluloid
4
4
  attr_reader :method, :arguments, :block
5
5
 
6
6
  def initialize(method, arguments = [], block = nil)
7
- @method, @arguments = method, arguments
7
+ @retry = 0
8
+ @method = method
9
+ @arguments = arguments
8
10
  if block
9
11
  if Celluloid.exclusive?
10
12
  # FIXME: nicer exception
11
- raise "Cannot execute blocks on sender in exclusive mode"
13
+ fail "Cannot execute blocks on sender in exclusive mode"
12
14
  end
13
- @block = BlockProxy.new(self, Celluloid.mailbox, block)
15
+ @block = Proxy::Block.new(self, Celluloid.mailbox, block)
14
16
  else
15
17
  @block = nil
16
18
  end
@@ -22,130 +24,39 @@ module Celluloid
22
24
 
23
25
  def dispatch(obj)
24
26
  check(obj)
25
- _block = @block && @block.to_proc
26
- obj.public_send(@method, *@arguments, &_block)
27
+ _b = @block && @block.to_proc
28
+ obj.public_send(@method, *@arguments, &_b)
29
+ # rescue Celluloid::TimeoutError => ex
30
+ # raise ex unless ( @retry += 1 ) <= RETRY_CALL_LIMIT
31
+ # puts "retrying"
32
+ # Internals::Logger.warn("TimeoutError at Call dispatch. Retrying in #{RETRY_CALL_WAIT} seconds. ( Attempt #{@retry} of #{RETRY_CALL_LIMIT} )")
33
+ # sleep RETRY_CALL_WAIT
34
+ # retry
27
35
  end
28
36
 
29
37
  def check(obj)
30
- raise NoMethodError, "undefined method `#{@method}' for #{obj.inspect}" unless obj.respond_to? @method
31
-
38
+ # NOTE: don't use respond_to? here
32
39
  begin
33
- arity = obj.method(@method).arity
40
+ meth = obj.method(@method)
34
41
  rescue NameError
35
- return
42
+ raise NoMethodError, "undefined method `#{@method}' for #<#{obj.class}:0x#{obj.object_id.to_s(16)}>"
36
43
  end
37
44
 
45
+ arity = meth.arity
46
+
38
47
  if arity >= 0
39
- raise ArgumentError, "wrong number of arguments (#{@arguments.size} for #{arity})" if @arguments.size != arity
48
+ fail ArgumentError, "wrong number of arguments (#{@arguments.size} for #{arity})" if @arguments.size != arity
40
49
  elsif arity < -1
41
50
  mandatory_args = -arity - 1
42
- raise ArgumentError, "wrong number of arguments (#{@arguments.size} for #{mandatory_args}+)" if arguments.size < mandatory_args
51
+ fail ArgumentError, "wrong number of arguments (#{@arguments.size} for #{mandatory_args}+)" if arguments.size < mandatory_args
43
52
  end
44
53
  rescue => ex
45
54
  raise AbortError.new(ex)
46
55
  end
47
56
  end
48
-
49
- # Synchronous calls wait for a response
50
- class SyncCall < Call
51
- attr_reader :sender, :task, :chain_id
52
-
53
- def initialize(sender, method, arguments = [], block = nil, task = Thread.current[:celluloid_task], chain_id = CallChain.current_id)
54
- super(method, arguments, block)
55
-
56
- @sender = sender
57
- @task = task
58
- @chain_id = chain_id || Celluloid.uuid
59
- end
60
-
61
- def dispatch(obj)
62
- CallChain.current_id = @chain_id
63
- result = super(obj)
64
- respond SuccessResponse.new(self, result)
65
- rescue Exception => ex
66
- # Exceptions that occur during synchronous calls are reraised in the
67
- # context of the sender
68
- respond ErrorResponse.new(self, ex)
69
-
70
- # Aborting indicates a protocol error on the part of the sender
71
- # It should crash the sender, but the exception isn't reraised
72
- # Otherwise, it's a bug in this actor and should be reraised
73
- raise unless ex.is_a?(AbortError)
74
- ensure
75
- CallChain.current_id = nil
76
- end
77
-
78
- def cleanup
79
- exception = DeadActorError.new("attempted to call a dead actor")
80
- respond ErrorResponse.new(self, exception)
81
- end
82
-
83
- def respond(message)
84
- @sender << message
85
- end
86
-
87
- def response
88
- Celluloid.suspend(:callwait, self)
89
- end
90
-
91
- def value
92
- response.value
93
- end
94
-
95
- def wait
96
- loop do
97
- message = Celluloid.mailbox.receive do |msg|
98
- msg.respond_to?(:call) and msg.call == self
99
- end
100
-
101
- if message.is_a?(SystemEvent)
102
- Thread.current[:celluloid_actor].handle_system_event(message)
103
- else
104
- # FIXME: add check for receiver block execution
105
- if message.respond_to?(:value)
106
- # FIXME: disable block execution if on :sender and (exclusive or outside of task)
107
- # probably now in Call
108
- break message
109
- else
110
- message.dispatch
111
- end
112
- end
113
- end
114
- end
115
- end
116
-
117
- # Asynchronous calls don't wait for a response
118
- class AsyncCall < Call
119
-
120
- def dispatch(obj)
121
- CallChain.current_id = Celluloid.uuid
122
- super(obj)
123
- rescue AbortError => ex
124
- # Swallow aborted async calls, as they indicate the sender made a mistake
125
- Logger.debug("#{obj.class}: async call `#@method` aborted!\n#{Logger.format_exception(ex.cause)}")
126
- ensure
127
- CallChain.current_id = nil
128
- end
129
-
130
- end
131
-
132
- class BlockCall
133
- def initialize(block_proxy, sender, arguments, task = Thread.current[:celluloid_task])
134
- @block_proxy = block_proxy
135
- @sender = sender
136
- @arguments = arguments
137
- @task = task
138
- end
139
- attr_reader :task
140
-
141
- def call
142
- @block_proxy.call
143
- end
144
-
145
- def dispatch
146
- response = @block_proxy.block.call(*@arguments)
147
- @sender << BlockResponse.new(self, response)
148
- end
149
- end
150
-
151
57
  end
58
+
59
+ require "celluloid/call/sync"
60
+ require "celluloid/call/async"
61
+ require "celluloid/call/block"
62
+ require "celluloid/call/block"
@@ -33,57 +33,69 @@ module Celluloid
33
33
  @actor.handle(Call) do |message|
34
34
  invoke(message)
35
35
  end
36
- @actor.handle(BlockCall) do |message|
36
+ @actor.handle(Call::Block) do |message|
37
37
  task(:invoke_block) { message.dispatch }
38
38
  end
39
- @actor.handle(BlockResponse, Response) do |message|
39
+ @actor.handle(Internals::Response::Block, Internals::Response) do |message|
40
40
  message.dispatch
41
41
  end
42
42
 
43
43
  @actor.start
44
- @proxy = (options[:proxy_class] || CellProxy).new(@actor.proxy, @actor.mailbox, @subject.class.to_s)
44
+ @proxy = (options[:proxy_class] || Proxy::Cell).new(@actor.proxy, @actor.mailbox, @subject.class.to_s)
45
45
  end
46
46
  attr_reader :proxy, :subject
47
47
 
48
+ def self.dispatch
49
+ proc do |subject|
50
+ subject[:call].dispatch(subject[:subject])
51
+ subject[:call] = nil
52
+ subject[:subject] = nil
53
+ end
54
+ end
55
+
48
56
  def invoke(call)
49
57
  meth = call.method
50
- if meth == :__send__
51
- meth = call.arguments.first
52
- end
58
+ meth = call.arguments.first if meth == :__send__
53
59
  if @receiver_block_executions && meth
54
60
  if @receiver_block_executions.include?(meth.to_sym)
55
61
  call.execute_block_on_receiver
56
62
  end
57
63
  end
58
64
 
59
- task(:call, meth, :dangerous_suspend => meth == :initialize) {
60
- call.dispatch(@subject)
61
- }
65
+ task(:call, meth, {call: call, subject: @subject},
66
+ dangerous_suspend: meth == :initialize, &Cell.dispatch)
62
67
  end
63
68
 
64
- def task(task_type, method_name = nil, meta = nil, &block)
69
+ def task(task_type, method_name = nil, subject = nil, meta = nil, &_block)
65
70
  meta ||= {}
66
- meta.merge!(:method_name => method_name)
71
+ meta.merge!(method_name: method_name)
67
72
  @actor.task(task_type, meta) do
68
73
  if @exclusive_methods && method_name && @exclusive_methods.include?(method_name.to_sym)
69
- Celluloid.exclusive { yield }
74
+ Celluloid.exclusive { yield subject }
70
75
  else
71
- yield
76
+ yield subject
72
77
  end
73
78
  end
74
79
  end
75
80
 
76
- # Run the user-defined finalizer, if one is set
77
- def shutdown
78
- return unless @finalizer && @subject.respond_to?(@finalizer, true)
79
-
80
- task(:finalizer, @finalizer, :dangerous_suspend => true) do
81
+ def self.shutdown
82
+ proc do |subject|
81
83
  begin
82
- @subject.__send__(@finalizer)
84
+ subject[:subject].__send__(subject[:call])
83
85
  rescue => ex
84
- Logger.crash("#{@subject.class} finalizer crashed!", ex)
86
+ Internals::Logger.crash("#{subject[:subject].class} finalizer crashed!", ex)
85
87
  end
88
+ subject[:call] = nil
89
+ subject[:subject] = nil
86
90
  end
87
91
  end
92
+
93
+ # Run the user-defined finalizer, if one is set
94
+ def shutdown
95
+ return unless @finalizer && @subject.respond_to?(@finalizer, true)
96
+
97
+ task(:finalizer, @finalizer, {call: @finalizer, subject: @subject},
98
+ dangerous_suspend: true, &Cell.shutdown)
99
+ end
88
100
  end
89
101
  end
@@ -36,7 +36,7 @@ module Celluloid
36
36
 
37
37
  # Wait for the given signal and return the associated value
38
38
  def wait(timeout = nil)
39
- raise ConditionError, "cannot wait for signals while exclusive" if Celluloid.exclusive?
39
+ fail ConditionError, "cannot wait for signals while exclusive" if Celluloid.exclusive?
40
40
 
41
41
  if actor = Thread.current[:celluloid_actor]
42
42
  task = Task.current
@@ -59,7 +59,7 @@ module Celluloid
59
59
 
60
60
  result = Celluloid.suspend :condwait, waiter
61
61
  timer.cancel if timer
62
- raise result if result.is_a? ConditionError
62
+ fail result if result.is_a? ConditionError
63
63
  result
64
64
  end
65
65
 
@@ -69,7 +69,7 @@ module Celluloid
69
69
  if waiter = @waiters.shift
70
70
  waiter << SignalConditionRequest.new(waiter.task, value)
71
71
  else
72
- Logger.with_backtrace(caller(3)) do |logger|
72
+ Internals::Logger.with_backtrace(caller(3)) do |logger|
73
73
  logger.debug("Celluloid::Condition signaled spuriously")
74
74
  end
75
75
  end
@@ -1,4 +1,4 @@
1
- require 'celluloid/fiber'
1
+ require "celluloid/fiber"
2
2
 
3
3
  class Thread
4
4
  attr_accessor :uuid_counter, :uuid_limit
@@ -0,0 +1,2 @@
1
+ $CELLULOID_BACKPORTED = false
2
+ require "celluloid/autostart"
@@ -0,0 +1,18 @@
1
+ class Thread
2
+ def self.mailbox
3
+ Celluloid.mailbox
4
+ end
5
+
6
+ def self.receive(timeout = nil, &block)
7
+ Celluloid.receive(timeout, &block)
8
+ end
9
+ end
10
+
11
+ # TODO: Remove link to Interal::Logger
12
+ module Celluloid
13
+ SyncCall = Call::Sync
14
+ EventedMailbox = Mailbox::Evented
15
+ InternalPool = Group::Pool
16
+ TaskThread = Task::Threaded
17
+ TaskFiber = Task::Fibered
18
+ end
@@ -17,7 +17,7 @@ module Celluloid
17
17
 
18
18
  def initialize(cause)
19
19
  @cause = cause
20
- super "caused by #{cause.inspect}: #{cause.to_s}"
20
+ super "caused by #{cause.inspect}: #{cause}"
21
21
  end
22
22
  end
23
23
  end
@@ -1,6 +1,6 @@
1
1
  # Fibers are hard... let's go shopping!
2
2
  begin
3
- require 'fiber'
3
+ require "fiber"
4
4
  rescue LoadError => ex
5
5
  if defined? JRUBY_VERSION
6
6
  if RUBY_VERSION < "1.9.2"
@@ -9,9 +9,9 @@ rescue LoadError => ex
9
9
 
10
10
  # Fibers are broken on JRuby 1.6.5. This works around the issue
11
11
  if JRUBY_VERSION[/^1\.6\.5/]
12
- require 'jruby'
12
+ require "jruby"
13
13
  org.jruby.ext.fiber.FiberExtLibrary.new.load(JRuby.runtime, false)
14
- class org::jruby::ext::fiber::ThreadFiber
14
+ class org.jruby.ext.fiber::ThreadFiber
15
15
  field_accessor :state
16
16
  end
17
17
 
@@ -1,4 +1,4 @@
1
- require 'thread'
1
+ require "thread"
2
2
 
3
3
  module Celluloid
4
4
  # Celluloid::Future objects allow methods and blocks to run in the
@@ -8,9 +8,9 @@ module Celluloid
8
8
  return super unless block
9
9
 
10
10
  future = new
11
- Celluloid::ThreadHandle.new(Celluloid.actor_system, :future) do
11
+ Internals::ThreadHandle.new(Celluloid.actor_system, :future) do
12
12
  begin
13
- call = SyncCall.new(future, :call, args)
13
+ call = Call::Sync.new(future, :call, args)
14
14
  call.dispatch(block)
15
15
  rescue
16
16
  # Exceptions in blocks will get raised when the value is retrieved
@@ -67,7 +67,7 @@ module Celluloid
67
67
  if result
68
68
  result.value
69
69
  else
70
- raise TimeoutError, "Timed out"
70
+ fail TimeoutError, "Timed out"
71
71
  end
72
72
  end
73
73
  alias_method :call, :value
@@ -77,7 +77,7 @@ module Celluloid
77
77
  result = Result.new(value, self)
78
78
 
79
79
  @mutex.synchronize do
80
- raise "the future has already happened!" if @ready
80
+ fail "the future has already happened!" if @ready
81
81
 
82
82
  if @forwards
83
83
  @forwards.is_a?(Array) ? @forwards.each { |f| f << result } : @forwards << result
@@ -97,7 +97,8 @@ module Celluloid
97
97
  attr_reader :future
98
98
 
99
99
  def initialize(result, future)
100
- @result, @future = result, future
100
+ @result = result
101
+ @future = future
101
102
  end
102
103
 
103
104
  def value