celluloid 0.13.0 → 0.14.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -2
  3. data/lib/celluloid.rb +84 -32
  4. data/lib/celluloid/actor.rb +35 -30
  5. data/lib/celluloid/autostart.rb +0 -13
  6. data/lib/celluloid/calls.rb +71 -23
  7. data/lib/celluloid/core_ext.rb +3 -14
  8. data/lib/celluloid/cpu_counter.rb +1 -1
  9. data/lib/celluloid/evented_mailbox.rb +82 -0
  10. data/lib/celluloid/fsm.rb +2 -0
  11. data/lib/celluloid/future.rb +4 -4
  12. data/lib/celluloid/internal_pool.rb +11 -8
  13. data/lib/celluloid/legacy.rb +14 -13
  14. data/lib/celluloid/logging/incident_logger.rb +2 -2
  15. data/lib/celluloid/mailbox.rb +16 -0
  16. data/lib/celluloid/method.rb +7 -7
  17. data/lib/celluloid/notifications.rb +1 -1
  18. data/lib/celluloid/proxies/abstract_proxy.rb +1 -1
  19. data/lib/celluloid/proxies/actor_proxy.rb +23 -27
  20. data/lib/celluloid/proxies/async_proxy.rb +18 -6
  21. data/lib/celluloid/proxies/block_proxy.rb +29 -0
  22. data/lib/celluloid/proxies/future_proxy.rb +9 -3
  23. data/lib/celluloid/proxies/sync_proxy.rb +31 -0
  24. data/lib/celluloid/receivers.rb +1 -1
  25. data/lib/celluloid/responses.rb +13 -1
  26. data/lib/celluloid/stack_dump.rb +8 -5
  27. data/lib/celluloid/supervision_group.rb +6 -4
  28. data/lib/celluloid/tasks.rb +63 -2
  29. data/lib/celluloid/tasks/task_fiber.rb +6 -46
  30. data/lib/celluloid/tasks/task_thread.rb +8 -44
  31. data/lib/celluloid/thread.rb +82 -0
  32. data/lib/celluloid/thread_handle.rb +3 -2
  33. data/lib/celluloid/version.rb +1 -1
  34. data/spec/support/actor_examples.rb +116 -53
  35. data/spec/support/example_actor_class.rb +7 -1
  36. data/spec/support/mailbox_examples.rb +29 -3
  37. data/spec/support/task_examples.rb +11 -9
  38. metadata +21 -29
@@ -1,9 +1,11 @@
1
1
  module ExampleActorClass
2
- def self.create(included_module)
2
+ def self.create(included_module, task_klass)
3
3
  Class.new do
4
4
  include included_module
5
+ task_class task_klass
5
6
  attr_reader :name
6
7
  finalizer :my_finalizer
8
+ execute_block_on_receiver :run_on_receiver
7
9
 
8
10
  def initialize(name)
9
11
  @name = name
@@ -30,6 +32,10 @@ module ExampleActorClass
30
32
  yield(*args)
31
33
  end
32
34
 
35
+ def run_on_receiver(*args)
36
+ yield(*args)
37
+ end
38
+
33
39
  def crash
34
40
  raise ExampleCrash, "the spec purposely crashed me :("
35
41
  end
@@ -25,9 +25,9 @@ shared_context "a Celluloid Mailbox" do
25
25
  subject << foo
26
26
  subject << bar
27
27
 
28
- subject.receive { |msg| msg.is_a? Foo }.should == foo
29
- subject.receive { |msg| msg.is_a? Bar }.should == bar
30
- subject.receive.should == baz
28
+ subject.receive { |msg| msg.is_a? Foo }.should eq(foo)
29
+ subject.receive { |msg| msg.is_a? Bar }.should eq(bar)
30
+ subject.receive.should eq(baz)
31
31
  end
32
32
 
33
33
  it "waits for a given timeout interval" do
@@ -37,4 +37,30 @@ shared_context "a Celluloid Mailbox" do
37
37
  subject.receive(interval) { false }
38
38
  (Time.now - started_at).should be_within(Celluloid::TIMER_QUANTUM).of interval
39
39
  end
40
+
41
+ it "has a size" do
42
+ subject.should respond_to(:size)
43
+ subject.size.should be_zero
44
+ subject << :foo
45
+ subject << :foo
46
+ subject.size.should be 2
47
+ end
48
+
49
+ it "discards messages received when when full" do
50
+ subject.max_size = 2
51
+ subject << :first
52
+ subject << :second
53
+ subject << :third
54
+ subject.to_a.should =~ [:first, :second]
55
+ end
56
+
57
+ it "logs discarded messages" do
58
+ Celluloid.logger = mock.as_null_object
59
+ Celluloid.logger.should_receive(:debug).with("Discarded message: third")
60
+
61
+ subject.max_size = 2
62
+ subject << :first
63
+ subject << :second
64
+ subject << :third
65
+ end
40
66
  end
@@ -1,12 +1,15 @@
1
- shared_context "a Celluloid Task" do |task_class|
2
- class MockActor
3
- attr_reader :tasks
1
+ class MockActor
2
+ attr_reader :tasks
4
3
 
5
- def initialize
6
- @tasks = []
7
- end
4
+ def initialize
5
+ @tasks = []
8
6
  end
9
7
 
8
+ def setup_thread
9
+ end
10
+ end
11
+
12
+ shared_context "a Celluloid Task" do |task_class|
10
13
  let(:task_type) { :foobar }
11
14
  let(:suspend_state) { :doing_something }
12
15
  let(:actor) { MockActor.new }
@@ -22,13 +25,13 @@ shared_context "a Celluloid Task" do |task_class|
22
25
  end
23
26
 
24
27
  it "begins with status :new" do
25
- subject.status.should == :new
28
+ subject.status.should be :new
26
29
  end
27
30
 
28
31
  it "resumes" do
29
32
  subject.should be_running
30
33
  subject.resume
31
- subject.status.should == suspend_state
34
+ subject.status.should eq(suspend_state)
32
35
  subject.resume
33
36
  subject.should_not be_running
34
37
  end
@@ -41,5 +44,4 @@ shared_context "a Celluloid Task" do |task_class|
41
44
  task.resume
42
45
  end.to raise_exception("failure")
43
46
  end
44
-
45
47
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
5
- prerelease:
4
+ version: 0.14.0.pre
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tony Arcieri
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-19 00:00:00.000000000 Z
11
+ date: 2013-05-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: timers
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: guard-rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: benchmark_suite
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: Celluloid enables people to build concurrent programs out of concurrent
@@ -106,6 +95,7 @@ files:
106
95
  - lib/celluloid/condition.rb
107
96
  - lib/celluloid/core_ext.rb
108
97
  - lib/celluloid/cpu_counter.rb
98
+ - lib/celluloid/evented_mailbox.rb
109
99
  - lib/celluloid/fiber.rb
110
100
  - lib/celluloid/fsm.rb
111
101
  - lib/celluloid/future.rb
@@ -126,7 +116,9 @@ files:
126
116
  - lib/celluloid/proxies/abstract_proxy.rb
127
117
  - lib/celluloid/proxies/actor_proxy.rb
128
118
  - lib/celluloid/proxies/async_proxy.rb
119
+ - lib/celluloid/proxies/block_proxy.rb
129
120
  - lib/celluloid/proxies/future_proxy.rb
121
+ - lib/celluloid/proxies/sync_proxy.rb
130
122
  - lib/celluloid/receivers.rb
131
123
  - lib/celluloid/registry.rb
132
124
  - lib/celluloid/responses.rb
@@ -139,6 +131,7 @@ files:
139
131
  - lib/celluloid/tasks/task_fiber.rb
140
132
  - lib/celluloid/tasks/task_thread.rb
141
133
  - lib/celluloid/tasks.rb
134
+ - lib/celluloid/thread.rb
142
135
  - lib/celluloid/thread_handle.rb
143
136
  - lib/celluloid/uuid.rb
144
137
  - lib/celluloid/version.rb
@@ -150,26 +143,25 @@ files:
150
143
  homepage: https://github.com/celluloid/celluloid
151
144
  licenses:
152
145
  - MIT
146
+ metadata: {}
153
147
  post_install_message:
154
148
  rdoc_options: []
155
149
  require_paths:
156
150
  - lib
157
151
  required_ruby_version: !ruby/object:Gem::Requirement
158
- none: false
159
152
  requirements:
160
- - - ! '>='
153
+ - - '>='
161
154
  - !ruby/object:Gem::Version
162
155
  version: 1.9.2
163
156
  required_rubygems_version: !ruby/object:Gem::Requirement
164
- none: false
165
157
  requirements:
166
- - - ! '>='
158
+ - - '>='
167
159
  - !ruby/object:Gem::Version
168
160
  version: 1.3.6
169
161
  requirements: []
170
162
  rubyforge_project:
171
- rubygems_version: 1.8.23
163
+ rubygems_version: 2.0.3
172
164
  signing_key:
173
- specification_version: 3
165
+ specification_version: 4
174
166
  summary: Actor-based concurrent object framework for Ruby
175
167
  test_files: []