diff --git a/src/tapedfunction.jl b/src/tapedfunction.jl index 15f0143c..2a7ac122 100644 --- a/src/tapedfunction.jl +++ b/src/tapedfunction.jl @@ -116,7 +116,12 @@ end @inline val(x::TapedFunction) = x.func @inline result(t::TapedFunction) = t.bindings[t.retval] -function (tf::TapedFunction)(args...; callback=nothing) +function (tf::TapedFunction)(args...; callback=nothing, continuation=false) + if !continuation # reset counter and retval to run from the start + tf.counter = 1; + tf.retval = :none; + end + # set args if tf.counter <= 1 haskey(tf.bindings, :_1) && _update_var!(tf, :_1, tf.func) diff --git a/src/tapedtask.jl b/src/tapedtask.jl index 6c49dc00..71656a30 100644 --- a/src/tapedtask.jl +++ b/src/tapedtask.jl @@ -32,7 +32,7 @@ end function wrap_task(tf, produce_ch, consume_ch, args...) try - tf(args...; callback=producer) + tf(args...; callback=producer, continuation=true) catch e bt = catch_backtrace() put!(produce_ch, TapedTaskException(e, bt))