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,45 @@
1
+ module Celluloid
2
+ class Task
3
+ # Tasks with a Fiber backend
4
+ class Fibered < Task
5
+ class StackError < Celluloid::Error; end
6
+ def create
7
+ queue = Thread.current[:celluloid_queue]
8
+ actor_system = Thread.current[:celluloid_actor_system]
9
+ @fiber = Fiber.new do
10
+ # FIXME: cannot use the writer as specs run inside normal Threads
11
+ Thread.current[:celluloid_role] = :actor
12
+ Thread.current[:celluloid_queue] = queue
13
+ Thread.current[:celluloid_actor_system] = actor_system
14
+ yield
15
+ # TODO: Determine why infinite thread leakage happens under jRuby, if `Fiber.yield` is used:
16
+ Fiber.yield unless RUBY_PLATFORM == "java"
17
+ end
18
+ end
19
+
20
+ def signal
21
+ Fiber.yield
22
+ end
23
+
24
+ # Resume a suspended task, giving it a value to return if needed
25
+ def deliver(value)
26
+ @fiber.resume value
27
+ rescue SystemStackError => ex
28
+ raise StackError, "#{ex} (please see https://github.com/celluloid/celluloid/wiki/Fiber-stack-errors)"
29
+ rescue FiberError => ex
30
+ raise DeadTaskError, "cannot resume a dead task (#{ex})"
31
+ end
32
+
33
+ # Terminate this task
34
+ def terminate
35
+ super
36
+ rescue FiberError
37
+ # If we're getting this the task should already be dead
38
+ end
39
+
40
+ def backtrace
41
+ ["#{self.class} backtrace unavailable. Please try `Celluloid.task_class = Celluloid::Task::Threaded` if you need backtraces here."]
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,59 @@
1
+ module Celluloid
2
+ class Task
3
+ # Tasks with a Thread backend
4
+ class Threaded < Task
5
+ # Run the given block within a task
6
+ def initialize(type, meta)
7
+ @resume_queue = Queue.new
8
+ @exception_queue = Queue.new
9
+ @yield_mutex = Mutex.new
10
+ @yield_cond = ConditionVariable.new
11
+ @thread = nil
12
+
13
+ super
14
+ end
15
+
16
+ def create
17
+ # TODO: move this to ActorSystem#get_thread (ThreadHandle inside Group::Pool)
18
+ thread = Internals::ThreadHandle.new(Thread.current[:celluloid_actor_system], :task) do
19
+ begin
20
+ ex = @resume_queue.pop
21
+ fail ex if ex.is_a?(Task::TerminatedError)
22
+
23
+ yield
24
+ rescue Exception => ex
25
+ @exception_queue << ex
26
+ ensure
27
+ @yield_mutex.synchronize do
28
+ @yield_cond.signal
29
+ end
30
+ end
31
+ end
32
+ @thread = thread
33
+ end
34
+
35
+ def signal
36
+ @yield_mutex.synchronize do
37
+ @yield_cond.signal
38
+ end
39
+ @resume_queue.pop
40
+ end
41
+
42
+ def deliver(value)
43
+ fail DeadTaskError, "cannot resume a dead task" unless @thread.alive?
44
+
45
+ @yield_mutex.synchronize do
46
+ @resume_queue.push(value)
47
+ @yield_cond.wait(@yield_mutex)
48
+ fail @exception_queue.pop while @exception_queue.size > 0
49
+ end
50
+ rescue ThreadError
51
+ raise DeadTaskError, "cannot resume a dead task"
52
+ end
53
+
54
+ def backtrace
55
+ @thread.backtrace
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,3 +1,3 @@
1
1
  $CELLULOID_TEST = true
2
2
 
3
- require 'celluloid'
3
+ require "celluloid"
@@ -1,4 +1,4 @@
1
- require 'celluloid/fiber'
1
+ require "celluloid/fiber"
2
2
 
3
3
  module Celluloid
4
4
  class Thread < ::Thread
@@ -36,5 +36,10 @@ module Celluloid
36
36
  def call_chain_id
37
37
  self[:celluloid_chain_id]
38
38
  end
39
+
40
+ def <<(proc)
41
+ self[:celluloid_queue] << proc
42
+ self
43
+ end
39
44
  end
40
45
  end
@@ -0,0 +1,3 @@
1
+ module Celluloid
2
+ VERSION = "0.17.0"
3
+ end
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe Celluloid, actor_system: :global do
3
+ RSpec.describe Celluloid do
4
4
  it_behaves_like "a Celluloid Actor", Celluloid
5
5
  end
@@ -1,47 +1,62 @@
1
- require 'spec_helper'
2
-
3
- describe Celluloid::ActorSystem do
1
+ RSpec.describe Celluloid::ActorSystem do
4
2
  class TestActor
5
3
  include Celluloid
4
+ def identity
5
+ :testing
6
+ end
7
+ end
8
+
9
+ after do
10
+ subject.shutdown
6
11
  end
7
12
 
8
13
  it "supports non-global ActorSystem" do
9
14
  subject.within do
10
- Celluloid.actor_system.should == subject
15
+ expect(Celluloid.actor_system).to eq(subject)
11
16
  end
12
17
  end
13
18
 
14
- it "starts default actors" do
19
+ it "makes actors accessible by Celluloid[:actor]" do
15
20
  subject.start
21
+ subject.within do
22
+ TestActor.supervise as: :testing, type: TestActor
23
+ expect(subject.registered).to include(:testing)
24
+ expect(Celluloid::Actor[:testing].identity).to eq(:testing)
25
+ end
26
+ end
16
27
 
17
- subject.registered.should == [:notifications_fanout, :default_incident_reporter]
28
+ it "starts default actors" do
29
+ subject.start
30
+ expect(subject.registered).to eq(Celluloid::ActorSystem::ROOT_SERVICES.map { |r| r[:as] })
18
31
  end
19
32
 
20
33
  it "support getting threads" do
21
34
  queue = Queue.new
22
- thread = subject.get_thread do
23
- Celluloid.actor_system.should == subject
35
+ subject.get_thread do
36
+ expect(Celluloid.actor_system).to eq(subject)
24
37
  queue << nil
25
38
  end
26
39
  queue.pop
27
40
  end
28
41
 
29
42
  it "allows a stack dump" do
30
- subject.stack_dump.should be_a(Celluloid::StackDump)
43
+ expect(subject.stack_dump).to be_a(Celluloid::Internals::Stack::Dump)
31
44
  end
32
45
 
33
- it "returns named actors" do
34
- subject.registered.should be_empty
46
+ it "allows a stack summary" do
47
+ expect(subject.stack_summary).to be_a(Celluloid::Internals::Stack::Summary)
48
+ end
35
49
 
50
+ it "returns named actors" do
51
+ subject.start
36
52
  subject.within do
37
- TestActor.supervise_as :test
53
+ TestActor.supervise as: :test
38
54
  end
39
-
40
- subject.registered.should == [:test]
55
+ expect(subject.registered).to include(:test)
41
56
  end
42
57
 
43
58
  it "returns running actors" do
44
- subject.running.should be_empty
59
+ expect(subject.running).to be_empty
45
60
 
46
61
  first = subject.within do
47
62
  TestActor.new
@@ -51,19 +66,18 @@ describe Celluloid::ActorSystem do
51
66
  TestActor.new
52
67
  end
53
68
 
54
- subject.running.should == [first, second]
69
+ expect(subject.running).to eq([first, second])
55
70
  end
56
71
 
57
72
  it "shuts down" do
58
73
  subject.shutdown
59
74
 
60
- lambda { subject.get_thread }.
61
- should raise_error("Thread pool is not running")
75
+ expect { subject.get_thread }
76
+ .to raise_error(Celluloid::Group::NotActive)
62
77
  end
63
78
 
64
79
  it "warns nicely when no actor system is started" do
65
- lambda { TestActor.new }.
66
- should raise_error("Celluloid is not yet started; use Celluloid.boot")
80
+ expect { TestActor.new }
81
+ .to raise_error("Celluloid is not yet started; use Celluloid.boot")
67
82
  end
68
-
69
83
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe "Blocks", actor_system: :global do
1
+ RSpec.describe "Blocks", actor_system: :global do
4
2
  class MyBlockActor
5
3
  include Celluloid
6
4
 
@@ -14,7 +12,7 @@ describe "Blocks", actor_system: :global do
14
12
  $data << [:outside, @name, current_actor.name]
15
13
  other.do_something_and_callback do |value|
16
14
  $data << [:yielded, @name, current_actor.name]
17
- $data << self.receive_result(:self)
15
+ $data << receive_result(:self)
18
16
  $data << current_actor.receive_result(:current_actor)
19
17
  $data << sender_actor.receive_result(:sender)
20
18
  "somevalue"
@@ -49,6 +47,6 @@ describe "Blocks", actor_system: :global do
49
47
  "somevalue",
50
48
  ]
51
49
 
52
- $data.should eq(expected)
50
+ expect($data).to eq(expected)
53
51
  end
54
52
  end
@@ -1,6 +1,5 @@
1
- require 'spec_helper'
2
-
3
- describe Celluloid::SyncCall, actor_system: :global do
1
+ RSpec.describe Celluloid::Call::Sync, actor_system: :global do
2
+ # TODO: these should be Call::Sync unit tests (without working on actual actors)
4
3
  class CallExampleActor
5
4
  include Celluloid
6
5
 
@@ -10,33 +9,56 @@ describe Celluloid::SyncCall, actor_system: :global do
10
9
 
11
10
  def actual_method; end
12
11
 
12
+ def inspect
13
+ fail "Don't call!"
14
+ end
15
+
13
16
  def chained_call_ids
14
17
  [call_chain_id, @next.call_chain_id]
15
18
  end
16
19
  end
17
20
 
18
21
  let(:actor) { CallExampleActor.new }
22
+ let(:logger) { Specs::FakeLogger.current }
19
23
 
20
- it "aborts with NoMethodError when a nonexistent method is called" do
21
- expect do
22
- actor.the_method_that_wasnt_there
23
- end.to raise_exception(NoMethodError)
24
+ context "when obj does not respond to a method" do
25
+ # bypass this until rubinius/rubinius#3373 is resolved
26
+ # under Rubinius, `method` calls `inspect` on an object when a method is not found
27
+ unless RUBY_ENGINE == "rbx"
28
+ it "raises a NoMethodError" do
29
+ allow(logger).to receive(:crash).with("Actor crashed!", NoMethodError)
30
+
31
+ expect do
32
+ actor.the_method_that_wasnt_there
33
+ end.to raise_exception(NoMethodError)
34
+ end
35
+ end
36
+
37
+ context "when obj raises during inspect" do
38
+ it "should emulate obj.inspect" do
39
+ allow(logger).to receive(:crash).with("Actor crashed!", NoMethodError)
24
40
 
25
- actor.should be_alive
41
+ if RUBY_ENGINE == "rbx"
42
+ expected = /undefined method `no_such_method' on an instance of CallExampleActor/
43
+ else
44
+ expected = /undefined method `no_such_method' for #\<CallExampleActor:0x[a-f0-9]+\>/
45
+ end
46
+ end
47
+ end
26
48
  end
27
49
 
28
50
  it "aborts with ArgumentError when a method is called with too many arguments" do
51
+ allow(logger).to receive(:crash).with("Actor crashed!", ArgumentError)
52
+
29
53
  expect do
30
54
  actor.actual_method("with too many arguments")
31
55
  end.to raise_exception(ArgumentError)
32
-
33
- actor.should be_alive
34
56
  end
35
57
 
36
58
  it "preserves call chains across synchronous calls" do
37
59
  actor2 = CallExampleActor.new(actor)
38
60
 
39
61
  uuid, next_actor_uuid = actor2.chained_call_ids
40
- uuid.should eq next_actor_uuid
62
+ expect(uuid).to eq next_actor_uuid
41
63
  end
42
64
  end
@@ -1,6 +1,6 @@
1
- require 'spec_helper'
1
+ RSpec.describe Celluloid::Condition, actor_system: :global do
2
+ let(:logger) { Specs::FakeLogger.current }
2
3
 
3
- describe Celluloid::Condition, actor_system: :global do
4
4
  class ConditionExample
5
5
  include Celluloid
6
6
 
@@ -29,7 +29,9 @@ describe Celluloid::Condition, actor_system: :global do
29
29
  value
30
30
  end
31
31
 
32
- def waiting?; @waiting end
32
+ def waiting?
33
+ @waiting
34
+ end
33
35
  end
34
36
 
35
37
  let(:actor) { ConditionExample.new }
@@ -37,40 +39,41 @@ describe Celluloid::Condition, actor_system: :global do
37
39
 
38
40
  it "sends signals" do
39
41
  3.times { actor.async.wait_for_condition }
40
- actor.signaled_times.should be_zero
42
+ expect(actor.signaled_times).to be_zero
41
43
 
42
44
  actor.condition.signal
43
- actor.signaled_times.should be(1)
45
+ expect(actor.signaled_times).to be(1)
44
46
  end
45
47
 
46
48
  it "broadcasts signals" do
47
49
  3.times { actor.async.wait_for_condition }
48
- actor.signaled_times.should be_zero
50
+ expect(actor.signaled_times).to be_zero
49
51
 
50
52
  actor.condition.broadcast
51
- actor.signaled_times.should be(3)
53
+ expect(actor.signaled_times).to be(3)
52
54
  end
53
55
 
54
56
  it "sends values along with signals" do
55
57
  future = actor.future(:wait_for_condition)
56
58
  actor.condition.signal(:example_value)
57
- future.value.should be(:example_value)
59
+ expect(future.value).to be(:example_value)
58
60
  end
59
61
 
60
62
  it "supports waiting outside actors" do
61
63
  condition = Celluloid::Condition.new
62
64
  actor.async.signal_condition condition, :value
63
- condition.wait.should eq(:value)
65
+ expect(condition.wait).to eq(:value)
64
66
  end
65
67
 
66
68
  it "times out inside normal Threads" do
67
69
  condition = Celluloid::Condition.new
68
- lambda { condition.wait(1) }.
69
- should raise_error(Celluloid::ConditionError)
70
+ expect { condition.wait(1) }
71
+ .to raise_error(Celluloid::ConditionError)
70
72
  end
71
73
 
72
74
  it "times out inside Tasks" do
73
- lambda { actor.wait_for_condition(1) }.
74
- should raise_error(Celluloid::ConditionError)
75
+ allow(logger).to receive(:crash).with("Actor crashed!", Celluloid::ConditionError)
76
+ expect { actor.wait_for_condition(1) }
77
+ .to raise_error(Celluloid::ConditionError)
75
78
  end
76
79
  end
@@ -1,34 +1,4 @@
1
- require 'spec_helper'
2
-
3
- class TestEventedMailbox < Celluloid::EventedMailbox
4
- class Reactor
5
- def initialize
6
- @condition = ConditionVariable.new
7
- @mutex = Mutex.new
8
- end
9
-
10
- def wakeup
11
- @mutex.synchronize do
12
- @condition.signal
13
- end
14
- end
15
-
16
- def run_once(timeout)
17
- @mutex.synchronize do
18
- @condition.wait(@mutex, timeout)
19
- end
20
- end
21
-
22
- def shutdown
23
- end
24
- end
25
-
26
- def initialize
27
- super(Reactor)
28
- end
29
- end
30
-
31
- describe Celluloid::EventedMailbox do
1
+ RSpec.describe Celluloid::Mailbox::Evented do
32
2
  subject { TestEventedMailbox.new }
33
3
  it_behaves_like "a Celluloid Mailbox"
34
4
  end