celluloid 0.14.0.pre → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/celluloid/supervision_group.rb +4 -6
- data/lib/celluloid/thread.rb +21 -11
- data/lib/celluloid/version.rb +1 -1
- data/spec/support/actor_examples.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14c9f61bd8924c3c5ab4265d3a7ca3d6c43e0fcc
|
4
|
+
data.tar.gz: 65e57a0119a677575a6fbf1663717812f3ca5e1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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}
|
133
|
-
|
134
|
-
|
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
|
|
data/lib/celluloid/thread.rb
CHANGED
@@ -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
|
-
|
45
|
+
actor = super(:celluloid_actor)
|
46
|
+
if !actor || CELLULOID_LOCALS.include?(key)
|
49
47
|
super(key)
|
50
48
|
else
|
51
|
-
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
|
-
|
55
|
+
actor = self[:celluloid_actor]
|
56
|
+
if !actor || CELLULOID_LOCALS.include?(key)
|
59
57
|
super(key, value)
|
60
58
|
else
|
61
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/celluloid/version.rb
CHANGED
@@ -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
|
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-
|
11
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timers
|