celluloid 0.14.0.pre → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e34a9a2d8dc0a227e68e1d8e5a7e4de3a6a99a5a
4
- data.tar.gz: 784898577b1163ff5a7756bd8fb4558e105b075c
3
+ metadata.gz: 14c9f61bd8924c3c5ab4265d3a7ca3d6c43e0fcc
4
+ data.tar.gz: 65e57a0119a677575a6fbf1663717812f3ca5e1c
5
5
  SHA512:
6
- metadata.gz: e1af2a80fa4944959773aac6b1b3c800d28a64810264e6e08b1d794ec46d40752efd8d144f7c63715acd40e8a5a9576aedc3bad6c8a59a7e4b336c0c37585373
7
- data.tar.gz: 0215cc3ab5bb87b222c9483563c4a4c89aac8ec78f6361715cb3dd2088a4908860aafaed8ec4e519f973ba29bbdaede4722973a0c4be3e177b42997aad5401d6
6
+ metadata.gz: 0f92f13dde36f666893891344073856a4283c402bf259bffa6d076aec33d3c607805ca84373fba854d198b17fe27415eee41283485b7cc4957f715aff00e9f06
7
+ data.tar.gz: 4b1cd7b742b028163e9a1af68343b5f3489997ced697383ae9e1737d01f0d9b4f16bc3406e8ea22f8c8668533e4a1ca2cb5a3184ce4b0b5cd7481b3e33e0944d
@@ -129,13 +129,11 @@ module Celluloid
129
129
  # when it is a pool, then we don't splat the args
130
130
  # and we need to extract the pool size if set
131
131
  if @pool
132
- options = {:args => @args}.tap do |hash|
133
- hash[:size] = @pool_size if @pool_size
134
- end
135
- @actor = @klass.send(@method, options, &@block)
136
- else
137
- @actor = @klass.send(@method, *@args, &@block)
132
+ options = {:args => @args}
133
+ options[:size] = @pool_size if @pool_size
134
+ @args = [options]
138
135
  end
136
+ @actor = @klass.send(@method, *@args, &@block)
139
137
  @registry[@name] = @actor if @name
140
138
  end
141
139
 
@@ -12,9 +12,6 @@ module Celluloid
12
12
  :celluloid_chain_id
13
13
  ]
14
14
 
15
- # A roundabout way to avoid purging :celluloid_queue
16
- EPHEMERAL_CELLULOID_LOCALS = CELLULOID_LOCALS - [:celluloid_queue]
17
-
18
15
  def celluloid?
19
16
  true
20
17
  end
@@ -45,38 +42,51 @@ module Celluloid
45
42
 
46
43
  # Obtain an actor-local value
47
44
  def [](key)
48
- if CELLULOID_LOCALS.include?(key)
45
+ actor = super(:celluloid_actor)
46
+ if !actor || CELLULOID_LOCALS.include?(key)
49
47
  super(key)
50
48
  else
51
- actor = super(:celluloid_actor)
52
- actor.locals[key] if actor
49
+ actor.locals[key]
53
50
  end
54
51
  end
55
52
 
56
53
  # Set an actor-local value
57
54
  def []=(key, value)
58
- if CELLULOID_LOCALS.include?(key)
55
+ actor = self[:celluloid_actor]
56
+ if !actor || CELLULOID_LOCALS.include?(key)
59
57
  super(key, value)
60
58
  else
61
- self[:celluloid_actor].locals[key] = value
59
+ actor.locals[key] = value
62
60
  end
63
61
  end
64
62
 
65
63
  # Obtain the keys to all actor-locals
66
64
  def keys
67
65
  actor = self[:celluloid_actor]
68
- actor.locals.keys if actor
66
+ if actor
67
+ actor.locals.keys
68
+ else
69
+ super
70
+ end
69
71
  end
70
72
 
71
73
  # Is the given actor local set?
72
74
  def key?(key)
73
75
  actor = self[:celluloid_actor]
74
- actor.locals.has_key?(key) if actor
76
+ if actor
77
+ actor.locals.has_key?(key)
78
+ else
79
+ super
80
+ end
75
81
  end
76
82
 
77
83
  # Clear thread state so it can be reused via thread pools
78
84
  def recycle
79
- EPHEMERAL_CELLULOID_LOCALS.each { |local| self[local] = nil }
85
+ # This thread local mediates access to the others, so we must clear it first
86
+ self[:celluloid_actor] = nil
87
+
88
+ # Clearing :celluloid_queue would break the thread pool!
89
+ keys.each { |key| self[key] = nil unless key == :celluloid_queue }
80
90
  end
81
91
  end
82
92
  end
@@ -1,4 +1,4 @@
1
1
  module Celluloid
2
- VERSION = '0.14.0.pre'
2
+ VERSION = '0.14.0'
3
3
  def self.version; VERSION; end
4
4
  end
@@ -336,6 +336,12 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
336
336
  def value
337
337
  Thread.current[:example_thread_local]
338
338
  end
339
+
340
+ def deferred_value
341
+ defer do
342
+ Thread.current[:example_thread_local]
343
+ end
344
+ end
339
345
  end
340
346
  end
341
347
 
@@ -345,6 +351,11 @@ shared_examples "Celluloid::Actor examples" do |included_module, task_klass|
345
351
  actor = example_class.new(example_value)
346
352
  actor.value.should eq example_value
347
353
  end
354
+
355
+ it "isolates thread locals in defer blocks" do
356
+ actor = example_class.new(example_value)
357
+ actor.deferred_value.should eq nil
358
+ end
348
359
  end
349
360
 
350
361
  context :linking do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0.pre
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-01 00:00:00.000000000 Z
11
+ date: 2013-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timers