ractorize 0.0.12 → 0.0.14
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/CHANGELOG.md +8 -0
- data/src/ractorize/ractorized_object/ractorized_ractor.rb +0 -1
- data/src/ractorize/ractorized_object.rb +12 -13
- data/src/ractorize/thunk.rb +2 -2
- data/src/ractorize.rb +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f251a64914d48582cef7e7de71c90217876aa54ee9cd5cf8aa0996c66eab3227
|
|
4
|
+
data.tar.gz: bf79ddf44caef84da4c0875982b4bee2ad32b0f9ee94e84e3cadb89fa98bab08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0efea3eeca4d2cc3c0e24c750c421a916d4f8d6540f9927f7d0ccbeef12ca4527aab0ec613f6412cd2ad131f30c19e7c6a5626d80ddbb4df1e3ba6839b7acfd
|
|
7
|
+
data.tar.gz: 807689cc00cc2e2186f2b094d0a1dd6f4f8d436599bfd46d0de08e08193ace7400502dd9e358f39b146e53593e93198cac31614bbc79fb30b131915bd3b31690
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [0.0.14] - 2026-08-14
|
|
2
|
+
|
|
3
|
+
- Make sure thunks are dethunked in predicate contexts involving blocks or chains of thunks
|
|
4
|
+
|
|
5
|
+
## [0.0.13] - 2026-08-13
|
|
6
|
+
|
|
7
|
+
- Calling methods with blocks no longer pre-emptively resolve thunks, avoiding potential deadlocks
|
|
8
|
+
|
|
1
9
|
## [0.0.12] - 2026-08-10
|
|
2
10
|
|
|
3
11
|
- Add ractor state to RactorizedObject#inspect
|
|
@@ -24,12 +24,7 @@ module Ractorize
|
|
|
24
24
|
@__target_object_id__ = ::Object.instance_method(:object_id).bind_call(outside_object)
|
|
25
25
|
@__target_class__ = outside_object.class
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
@__ractor__ << outside_object
|
|
29
|
-
else
|
|
30
|
-
::Ractorize.resolve_all_thunks(outside_object)
|
|
31
|
-
@__ractor__.send(outside_object, move: true)
|
|
32
|
-
end
|
|
27
|
+
@__ractor__.send(outside_object, move: true)
|
|
33
28
|
when :class
|
|
34
29
|
klass, *args = args
|
|
35
30
|
|
|
@@ -93,7 +88,10 @@ module Ractorize
|
|
|
93
88
|
end
|
|
94
89
|
|
|
95
90
|
return_port = ::Ractorize::RactorizedObject::RactorizedRactor::Port.new
|
|
96
|
-
|
|
91
|
+
|
|
92
|
+
can_use_thunk = RactorizedObject.method_should_use_thunk?(method_name)
|
|
93
|
+
|
|
94
|
+
thunk_ractor = if !block && can_use_thunk
|
|
97
95
|
::Ractorize::Thunk::ThunkRactor.new
|
|
98
96
|
end
|
|
99
97
|
|
|
@@ -139,14 +137,11 @@ module Ractorize
|
|
|
139
137
|
in :yield, [yielded_args, yielded_opts, yielded_block], block_result_port
|
|
140
138
|
# TODO: yielded_block likely won't work when actually used
|
|
141
139
|
# so we should probably instead just raise an exception
|
|
142
|
-
# TODO: handle break and also raise in the block
|
|
143
140
|
begin
|
|
144
141
|
broke = true
|
|
145
142
|
block_result = block.call(*yielded_args.freeze, **yielded_opts.freeze, &yielded_block)
|
|
146
143
|
broke = false
|
|
147
144
|
ensure
|
|
148
|
-
block_result = block_result.__value__ while ::Ractorize::Thunk === block_result
|
|
149
|
-
|
|
150
145
|
block_result_port << if broke
|
|
151
146
|
# TODO: handle error situation
|
|
152
147
|
:break
|
|
@@ -157,6 +152,11 @@ module Ractorize
|
|
|
157
152
|
end
|
|
158
153
|
end
|
|
159
154
|
|
|
155
|
+
unless can_use_thunk
|
|
156
|
+
# It's important we don't accidentally return a thunk (truthy) instead of nil/false (falsey)
|
|
157
|
+
value = value.__value__ while ::Ractorize::Thunk === value
|
|
158
|
+
end
|
|
159
|
+
|
|
160
160
|
value
|
|
161
161
|
# Let's assume the user would rather block on all predicate methods than
|
|
162
162
|
# incorrectly get a non-truthy value (thunk is always truthy even if it evaluates as nil/false)
|
|
@@ -167,9 +167,8 @@ module Ractorize
|
|
|
167
167
|
value = return_port.receive
|
|
168
168
|
return_port.close
|
|
169
169
|
|
|
170
|
-
#
|
|
171
|
-
|
|
172
|
-
# simplecov:enable
|
|
170
|
+
# It's important we don't accidentally return a thunk (truthy) instead of nil/false (falsey)
|
|
171
|
+
value = value.__value__ while ::Ractorize::Thunk === value
|
|
173
172
|
|
|
174
173
|
value
|
|
175
174
|
end
|
data/src/ractorize/thunk.rb
CHANGED
|
@@ -4,8 +4,8 @@ module Ractorize
|
|
|
4
4
|
|
|
5
5
|
attr_accessor :__thunk_ractor__, :__object_id__
|
|
6
6
|
|
|
7
|
-
def initialize(
|
|
8
|
-
self.__thunk_ractor__ =
|
|
7
|
+
def initialize(return_value_ractor)
|
|
8
|
+
self.__thunk_ractor__ = return_value_ractor
|
|
9
9
|
self.__object_id__ = ::Object.instance_method(:object_id).bind_call(self)
|
|
10
10
|
::Ractorize::GarbageCollection.track_thunk(self)
|
|
11
11
|
end
|
data/src/ractorize.rb
CHANGED