celluloid 0.12.0.pre2 → 0.12.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
@@ -143,8 +143,16 @@ module Celluloid
143
143
  end
144
144
 
145
145
  # Define the default task type for this class
146
- def task_class(klass)
147
- @task_class = klass
146
+ def task_class(klass = nil)
147
+ if klass
148
+ @task_class = klass
149
+ elsif defined?(@task_class)
150
+ @task_class
151
+ elsif superclass.respond_to? :task_class
152
+ superclass.task_class
153
+ else
154
+ Celluloid.task_class
155
+ end
148
156
  end
149
157
 
150
158
  # Mark methods as running exclusively
@@ -174,7 +182,7 @@ module Celluloid
174
182
  :mailbox => mailbox_factory,
175
183
  :exit_handler => @exit_handler,
176
184
  :exclusive_methods => @exclusive_methods,
177
- :task_class => @task_class
185
+ :task_class => task_class
178
186
  }
179
187
  end
180
188
 
@@ -364,13 +372,21 @@ module Celluloid
364
372
  end
365
373
 
366
374
  # Handle async calls within an actor itself
367
- def async(meth, *args, &block)
368
- Actor.async Thread.current[:actor].mailbox, meth, *args, &block
375
+ def async(meth = nil, *args, &block)
376
+ if meth
377
+ Actor.async Thread.current[:actor].mailbox, meth, *args, &block
378
+ else
379
+ Thread.current[:actor].proxy.async
380
+ end
369
381
  end
370
382
 
371
383
  # Handle calls to future within an actor itself
372
- def future(meth, *args, &block)
373
- Actor.future Thread.current[:actor].mailbox, meth, *args, &block
384
+ def future(meth = nil, *args, &block)
385
+ if meth
386
+ Actor.future Thread.current[:actor].mailbox, meth, *args, &block
387
+ else
388
+ Thread.current[:actor].proxy.future
389
+ end
374
390
  end
375
391
  end
376
392
 
@@ -6,6 +6,9 @@ module Celluloid
6
6
 
7
7
  def initialize(actor)
8
8
  @mailbox, @thread, @klass = actor.mailbox, actor.thread, actor.subject.class.to_s
9
+
10
+ @async_proxy = AsyncProxy.new(actor)
11
+ @future_proxy = FutureProxy.new(actor)
9
12
  end
10
13
 
11
14
  def class
@@ -59,7 +62,7 @@ module Celluloid
59
62
  if method_name
60
63
  Actor.async @mailbox, method_name, *args, &block
61
64
  else
62
- AsyncProxy.new(@mailbox, @klass)
65
+ @async_proxy
63
66
  end
64
67
  end
65
68
 
@@ -68,7 +71,7 @@ module Celluloid
68
71
  if method_name
69
72
  Actor.future @mailbox, method_name, *args, &block
70
73
  else
71
- FutureProxy.new(@mailbox, @klass)
74
+ @future_proxy
72
75
  end
73
76
  end
74
77
 
@@ -3,8 +3,8 @@ module Celluloid
3
3
  class AsyncProxy < AbstractProxy
4
4
  attr_reader :mailbox
5
5
 
6
- def initialize(mailbox, klass)
7
- @mailbox, @klass = mailbox, klass
6
+ def initialize(actor)
7
+ @mailbox, @klass = actor.mailbox, actor.subject.class.to_s
8
8
  end
9
9
 
10
10
  def inspect
@@ -3,8 +3,8 @@ module Celluloid
3
3
  class FutureProxy < AbstractProxy
4
4
  attr_reader :mailbox
5
5
 
6
- def initialize(mailbox, klass)
7
- @mailbox, @klass = mailbox, klass
6
+ def initialize(actor)
7
+ @mailbox, @klass = actor.mailbox, actor.subject.class.to_s
8
8
  end
9
9
 
10
10
  def inspect
@@ -59,7 +59,7 @@ module Celluloid
59
59
 
60
60
  # Nicer string inspect for tasks
61
61
  def inspect
62
- "<Celluloid::Task:0x#{object_id.to_s(16)} @type=#{@type.inspect}, @status=#{@status.inspect}>"
62
+ "<Celluloid::TaskFiber:0x#{object_id.to_s(16)} @type=#{@type.inspect}, @status=#{@status.inspect}>"
63
63
  end
64
64
  end
65
65
  end
@@ -73,7 +73,7 @@ module Celluloid
73
73
 
74
74
  # Nicer string inspect for tasks
75
75
  def inspect
76
- "<Celluloid::Task:0x#{object_id.to_s(16)} @type=#{@type.inspect}, @status=#{@status.inspect}>"
76
+ "<Celluloid::TaskThread:0x#{object_id.to_s(16)} @type=#{@type.inspect}, @status=#{@status.inspect}>"
77
77
  end
78
78
  end
79
79
  end
@@ -1,4 +1,4 @@
1
1
  module Celluloid
2
- VERSION = '0.12.0.pre2'
2
+ VERSION = '0.12.0.pre3'
3
3
  def self.version; VERSION; end
4
4
  end
@@ -160,7 +160,13 @@ shared_context "a Celluloid Actor" do |included_module|
160
160
  actor.greet.should == "Hi, I'm Charlie Sheen"
161
161
  end
162
162
 
163
- it "supports asynchronous calls to itself" do
163
+ it "supports method! syntax for asynchronous calls to itself" do
164
+ actor = actor_class.new "Troy McClure"
165
+ actor.change_name_with_a_bang "Charlie Sheen"
166
+ actor.greet.should == "Hi, I'm Charlie Sheen"
167
+ end
168
+
169
+ it "supports async.method syntax for asynchronous calls to itself" do
164
170
  actor = actor_class.new "Troy McClure"
165
171
  actor.change_name_async "Charlie Sheen"
166
172
  actor.greet.should == "Hi, I'm Charlie Sheen"
@@ -675,8 +681,13 @@ shared_context "a Celluloid Actor" do |included_module|
675
681
  end
676
682
  end
677
683
 
678
- it "uses user-specified tasks" do
684
+ it "overrides the task class" do
679
685
  subject.new.tasks.first.should be_a ExampleTask
680
686
  end
687
+
688
+ it "retains custom task classes when subclassed" do
689
+ subclass = Class.new(subject)
690
+ subclass.new.tasks.first.should be_a ExampleTask
691
+ end
681
692
  end
682
693
  end
@@ -13,10 +13,14 @@ module ExampleActorClass
13
13
  @name = new_name
14
14
  end
15
15
 
16
- def change_name_async(new_name)
16
+ def change_name_with_a_bang(new_name)
17
17
  change_name! new_name
18
18
  end
19
19
 
20
+ def change_name_async(new_name)
21
+ async.change_name new_name
22
+ end
23
+
20
24
  def greet
21
25
  "Hi, I'm #{@name}"
22
26
  end
metadata CHANGED
@@ -1,61 +1,62 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.12.0.pre3
4
5
  prerelease: 7
5
- version: 0.12.0.pre2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tony Arcieri
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-03 00:00:00.000000000Z
12
+ date: 2012-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: timers
16
- version_requirements: &2056 !ruby/object:Gem::Requirement
16
+ requirement: &70304033561060 !ruby/object:Gem::Requirement
17
+ none: false
17
18
  requirements:
18
19
  - - ! '>='
19
20
  - !ruby/object:Gem::Version
20
21
  version: 1.0.0
21
- none: false
22
- requirement: *2056
23
- prerelease: false
24
22
  type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70304033561060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- version_requirements: &2074 !ruby/object:Gem::Requirement
27
+ requirement: &70304033560520 !ruby/object:Gem::Requirement
28
+ none: false
28
29
  requirements:
29
30
  - - ! '>='
30
31
  - !ruby/object:Gem::Version
31
32
  version: '0'
32
- none: false
33
- requirement: *2074
34
- prerelease: false
35
33
  type: :development
34
+ prerelease: false
35
+ version_requirements: *70304033560520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- version_requirements: &2092 !ruby/object:Gem::Requirement
38
+ requirement: &70304033559840 !ruby/object:Gem::Requirement
39
+ none: false
39
40
  requirements:
40
41
  - - ! '>='
41
42
  - !ruby/object:Gem::Version
42
43
  version: '0'
43
- none: false
44
- requirement: *2092
45
- prerelease: false
46
44
  type: :development
45
+ prerelease: false
46
+ version_requirements: *70304033559840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: benchmark_suite
49
- version_requirements: &2108 !ruby/object:Gem::Requirement
49
+ requirement: &70304033559280 !ruby/object:Gem::Requirement
50
+ none: false
50
51
  requirements:
51
52
  - - ! '>='
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
- none: false
55
- requirement: *2108
56
- prerelease: false
57
55
  type: :development
58
- description: Celluloid enables people to build concurrent programs out of concurrent objects just as easily as they build sequential programs out of sequential objects
56
+ prerelease: false
57
+ version_requirements: *70304033559280
58
+ description: Celluloid enables people to build concurrent programs out of concurrent
59
+ objects just as easily as they build sequential programs out of sequential objects
59
60
  email:
60
61
  - tony.arcieri@gmail.com
61
62
  executables: []
@@ -63,7 +64,6 @@ extensions: []
63
64
  extra_rdoc_files: []
64
65
  files:
65
66
  - README.md
66
- - lib/celluloid.rb
67
67
  - lib/celluloid/actor.rb
68
68
  - lib/celluloid/boot.rb
69
69
  - lib/celluloid/calls.rb
@@ -79,6 +79,10 @@ files:
79
79
  - lib/celluloid/method.rb
80
80
  - lib/celluloid/notifications.rb
81
81
  - lib/celluloid/pool_manager.rb
82
+ - lib/celluloid/proxies/abstract_proxy.rb
83
+ - lib/celluloid/proxies/actor_proxy.rb
84
+ - lib/celluloid/proxies/async_proxy.rb
85
+ - lib/celluloid/proxies/future_proxy.rb
82
86
  - lib/celluloid/receivers.rb
83
87
  - lib/celluloid/registry.rb
84
88
  - lib/celluloid/responses.rb
@@ -88,15 +92,12 @@ files:
88
92
  - lib/celluloid/supervisor.rb
89
93
  - lib/celluloid/system_events.rb
90
94
  - lib/celluloid/task.rb
95
+ - lib/celluloid/tasks/task_fiber.rb
96
+ - lib/celluloid/tasks/task_thread.rb
91
97
  - lib/celluloid/thread_handle.rb
92
98
  - lib/celluloid/uuid.rb
93
99
  - lib/celluloid/version.rb
94
- - lib/celluloid/proxies/abstract_proxy.rb
95
- - lib/celluloid/proxies/actor_proxy.rb
96
- - lib/celluloid/proxies/async_proxy.rb
97
- - lib/celluloid/proxies/future_proxy.rb
98
- - lib/celluloid/tasks/task_fiber.rb
99
- - lib/celluloid/tasks/task_thread.rb
100
+ - lib/celluloid.rb
100
101
  - spec/support/actor_examples.rb
101
102
  - spec/support/example_actor_class.rb
102
103
  - spec/support/mailbox_examples.rb
@@ -104,28 +105,26 @@ files:
104
105
  homepage: https://github.com/celluloid/celluloid
105
106
  licenses:
106
107
  - MIT
107
- post_install_message:
108
+ post_install_message:
108
109
  rdoc_options: []
109
110
  require_paths:
110
111
  - lib
111
112
  required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
112
114
  requirements:
113
115
  - - ! '>='
114
116
  - !ruby/object:Gem::Version
115
117
  version: 1.9.2
116
- none: false
117
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
118
120
  requirements:
119
121
  - - ! '>='
120
122
  - !ruby/object:Gem::Version
121
123
  version: 1.3.6
122
- none: false
123
124
  requirements: []
124
- rubyforge_project:
125
- rubygems_version: 1.8.15
126
- signing_key:
125
+ rubyforge_project:
126
+ rubygems_version: 1.8.17
127
+ signing_key:
127
128
  specification_version: 3
128
129
  summary: Actor-based concurrent object framework for Ruby
129
130
  test_files: []
130
- has_rdoc:
131
- ...