File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -237,6 +237,22 @@ function TapedTask(taped_globals::Any, fargs...; kwargs...)
237
237
return TapedTask (taped_globals, all_args, mc, count_ref)
238
238
end
239
239
240
+ """
241
+ fresh_copy(mc::T) where {T<:MistyClosure}
242
+
243
+ Creates an independent copy of `mc` by (carefully) replacing the `Ref`s it
244
+ contains it its `captures`. The resuting `MistyClosure` is safe to run.
245
+
246
+ This is achieved by replacing most `Ref`s with new `Ref`s of the same (el)type,
247
+ but with nothing stored in them -- values will be stored in them when the
248
+ new `MistyClosure` is called. The only exception are `DynamicCallable`s and
249
+ `LazyCallable`s -- these are constructed when the `MistyClosure`s IR is derived,
250
+ so fresh instances of them are placed in the associated `Ref`.
251
+
252
+ The position counter is reset to `-1` (indicating that execution should proceed
253
+ from the start of the IR, rather than eg. jumping to a line following a
254
+ `produce` statement.
255
+ """
240
256
function fresh_copy (mc:: T ) where {T<: MistyClosure }
241
257
new_captures = map (mc. oc. captures) do r
242
258
if eltype (r) <: DynamicCallable
You can’t perform that action at this time.
0 commit comments