From 3b58ca368ec01d9501d7d97567cbade466749743 Mon Sep 17 00:00:00 2001 From: Hong Ge Date: Fri, 25 Mar 2022 22:13:50 +0000 Subject: [PATCH 1/4] Bugfix in running TapedFunction. --- src/tapedfunction.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tapedfunction.jl b/src/tapedfunction.jl index 15f0143c..67a17bc8 100644 --- a/src/tapedfunction.jl +++ b/src/tapedfunction.jl @@ -117,6 +117,10 @@ end @inline result(t::TapedFunction) = t.bindings[t.retval] function (tf::TapedFunction)(args...; callback=nothing) + # reset counter and retval + tf.counter = 1; + tf.retval = :none; + # set args if tf.counter <= 1 haskey(tf.bindings, :_1) && _update_var!(tf, :_1, tf.func) From cb729b9913ee3ec07da13a855966599ebfde3d86 Mon Sep 17 00:00:00 2001 From: KDr2 Date: Sat, 26 Mar 2022 07:55:52 +0800 Subject: [PATCH 2/4] don't rest counter in tapedtask --- src/tapedfunction.jl | 9 +++++---- src/tapedtask.jl | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tapedfunction.jl b/src/tapedfunction.jl index 67a17bc8..a71b39f3 100644 --- a/src/tapedfunction.jl +++ b/src/tapedfunction.jl @@ -116,10 +116,11 @@ end @inline val(x::TapedFunction) = x.func @inline result(t::TapedFunction) = t.bindings[t.retval] -function (tf::TapedFunction)(args...; callback=nothing) - # reset counter and retval - tf.counter = 1; - tf.retval = :none; +function (tf::TapedFunction)(args...; callback=nothing, startover=true) + if startover # reset counter and retval to run from the start + tf.counter = 1; + tf.retval = :none; + end # set args if tf.counter <= 1 diff --git a/src/tapedtask.jl b/src/tapedtask.jl index 6c49dc00..dff2c8dc 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, startover=false) catch e bt = catch_backtrace() put!(produce_ch, TapedTaskException(e, bt)) From 8cd38a290a285706bccb3254e7d1892a01d27e1a Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Sat, 26 Mar 2022 09:25:43 +0000 Subject: [PATCH 3/4] Apply suggestions from code review --- src/tapedfunction.jl | 4 ++-- src/tapedtask.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tapedfunction.jl b/src/tapedfunction.jl index a71b39f3..0f68a65e 100644 --- a/src/tapedfunction.jl +++ b/src/tapedfunction.jl @@ -116,8 +116,8 @@ end @inline val(x::TapedFunction) = x.func @inline result(t::TapedFunction) = t.bindings[t.retval] -function (tf::TapedFunction)(args...; callback=nothing, startover=true) - if startover # reset counter and retval to run from the start +function (tf::TapedFunction)(args...; callback=nothing, continue=false) + if !continue # reset counter and retval to run from the start tf.counter = 1; tf.retval = :none; end diff --git a/src/tapedtask.jl b/src/tapedtask.jl index dff2c8dc..85776738 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, startover=false) + tf(args...; callback=producer, continue=true) catch e bt = catch_backtrace() put!(produce_ch, TapedTaskException(e, bt)) From cd179d13fc28c45b32feee4395c6d33aa40d6c6c Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Sat, 26 Mar 2022 09:27:48 +0000 Subject: [PATCH 4/4] Apply suggestions from code review --- src/tapedfunction.jl | 4 ++-- src/tapedtask.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tapedfunction.jl b/src/tapedfunction.jl index 0f68a65e..2a7ac122 100644 --- a/src/tapedfunction.jl +++ b/src/tapedfunction.jl @@ -116,8 +116,8 @@ end @inline val(x::TapedFunction) = x.func @inline result(t::TapedFunction) = t.bindings[t.retval] -function (tf::TapedFunction)(args...; callback=nothing, continue=false) - if !continue # reset counter and retval to run from the start +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 diff --git a/src/tapedtask.jl b/src/tapedtask.jl index 85776738..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, continue=true) + tf(args...; callback=producer, continuation=true) catch e bt = catch_backtrace() put!(produce_ch, TapedTaskException(e, bt))