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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3042e08702fb4a92c9d7f0fadf6f037c5ae271652ab0315450f4b659619a7670
4
- data.tar.gz: ddae0a3a1f517f0ea88062e5e1ae01f6c6387b1906d6a7ff52334b95e86a9229
3
+ metadata.gz: f251a64914d48582cef7e7de71c90217876aa54ee9cd5cf8aa0996c66eab3227
4
+ data.tar.gz: bf79ddf44caef84da4c0875982b4bee2ad32b0f9ee94e84e3cadb89fa98bab08
5
5
  SHA512:
6
- metadata.gz: 3b24356eaf34b3cd555b7915004a75b6c2f19da4b91f27dec2bdf6d9d3f694c418f1c6b3ed8b98b316b71afd678c3b73e19999ed00779203b45f5f17a8fd366f
7
- data.tar.gz: 5e7267529748509b06b58394544696eac1a7600cb33d1971d299e842ee4b1c58b96a8b239b467c2e661cb3499e0894888fc1bef302d62c099b269803a021e27b
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
@@ -89,7 +89,6 @@ module Ractorize
89
89
  return_port << [:return, value].freeze
90
90
  else
91
91
  value = object.__send__(method_name, *method_args, **opts)
92
- value = value.__value__ while Ractorize::Thunk === value
93
92
 
94
93
  begin
95
94
  if thunk_ractor
@@ -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
- if ::Ractor.shareable?(outside_object)
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
- thunk_ractor = if !block && RactorizedObject.method_should_use_thunk?(method_name)
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
- # simplecov:disable
171
- ::Kernel.raise ::Ractorize::Thunk::EscapingRactorError if ::Ractorize::Thunk === value
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
@@ -4,8 +4,8 @@ module Ractorize
4
4
 
5
5
  attr_accessor :__thunk_ractor__, :__object_id__
6
6
 
7
- def initialize(return_value_portlike)
8
- self.__thunk_ractor__ = return_value_portlike
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
@@ -157,8 +157,6 @@ module Ractorize
157
157
 
158
158
  args.each { apply_auto_freeze(target_class, it) }
159
159
 
160
- ::Ractorize.resolve_all_thunks(args)
161
-
162
160
  return nil if skip_move
163
161
 
164
162
  to_move(target_class, args)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ractorize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi