Skip to content

Commit 57ee7fe

Browse files
author
KDr2
committed
set state of task after it is queued
1 parent dc2bff5 commit 57ee7fe

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/taskcopy.jl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,16 @@ function task_wrapper(func)
4343
res = func()
4444
ct = current_task()
4545
ct.result = res
46-
@static if VERSION >= v"1.1.0"
47-
ct.state = :done
48-
end
46+
isa(ct.storage, Nothing) && (ct.storage = IdDict())
47+
ct.storage[:_libtask_state] = :done
4948
wait()
5049
catch ex
5150
ct = current_task()
5251
ct.exception = ex
5352
ct.result = ex
54-
@static if VERSION >= v"1.1.0"
55-
ct.state = :failed
56-
end
5753
ct.backtrace = catch_backtrace()
54+
isa(ct.storage, Nothing) && (ct.storage = IdDict())
55+
ct.storage[:_libtask_state] = :failed
5856
wait()
5957
end
6058
end
@@ -173,10 +171,10 @@ consume(p::Task, values...) = begin
173171
Base.schedule(p)
174172
yield()
175173

174+
isa(p.storage, IdDict) && haskey(p.storage, :_libtask_state) &&
175+
(p.state = p.storage[:_libtask_state])
176+
176177
if p.exception != nothing
177-
@static if VERSION < v"1.1.0"
178-
p.state = :failed
179-
end
180178
throw(p.exception)
181179
end
182180
end

0 commit comments

Comments
 (0)