Skip to content

Commit c81dab8

Browse files
authored
Extract TapedTask try-catch method (#120)
1 parent 8aaea77 commit c81dab8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/tapedtask.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ struct TapedTask
1616
end
1717
end
1818

19-
function TapedTask(tf::TapedFunction, args...)
20-
produce_ch = Channel()
21-
consume_ch = Channel{Int}()
22-
task = @task try
19+
function wrap_task(tf, produce_ch, consume_ch, args...)
20+
try
2321
producer = () -> begin
2422
ttask = current_task().storage[:tapedtask]
2523
if length(ttask.produced_val) > 0
@@ -45,6 +43,12 @@ function TapedTask(tf::TapedFunction, args...)
4543
close(produce_ch)
4644
close(consume_ch)
4745
end
46+
end
47+
48+
function TapedTask(tf::TapedFunction, args...)
49+
produce_ch = Channel()
50+
consume_ch = Channel{Int}()
51+
task = @task wrap_task(tf, produce_ch, consume_ch, args...)
4852
t = TapedTask(task, tf, produce_ch, consume_ch)
4953
task.storage === nothing && (task.storage = IdDict())
5054
task.storage[:tapedtask] = t

0 commit comments

Comments
 (0)