2424
2525function Base. showerror (io:: IO , ex:: CTaskException )
2626 println (io, " CTaskException:" )
27- showerror (io, getproperty (ex. task, :exception ), getproperty (ex. task, :backtrace ))
27+ bt = @static if VERSION < v " 1.6.0-DEV.1145"
28+ ct. backtrace
29+ else
30+ ct. storage[:_libtask_bt ]
31+ end
32+ showerror (io, ex. task. exception, bt)
2833end
2934
3035# Utility function for self-copying mechanism
@@ -37,7 +42,7 @@ function n_copies(t::Task)
3742end
3843
3944function enable_stack_copying (t:: Task )
40- state = getproperty (t, : state)
45+ state = t . state
4146 if state != = :runnable && state != = :done
4247 error (" only runnable or finished tasks' stack can be copied." )
4348 end
@@ -72,11 +77,12 @@ function task_wrapper(func)
7277 ct = _current_task ()
7378 @static if VERSION < v " 1.6.0-DEV.1145"
7479 ct. exception = ex
80+ ct. backtrace = catch_backtrace ()
7581 else
7682 ct. _isexception = true
83+ ct. storage[:_libtask_bt ] = catch_backtrace ()
7784 end
7885 ct. result = ex
79- ct. backtrace = catch_backtrace ()
8086 ct. storage === nothing && (ct. storage = IdDict ())
8187 ct. storage[:_libtask_state ] = :failed
8288 wait ()
8894
8995function Base. copy (ctask:: CTask )
9096 task = ctask. task
91- state = getproperty ( task, : state)
97+ state = task. state
9298 if state != = :runnable && state != = :done
9399 error (" only runnable or finished tasks can be copied." )
94100 end
@@ -139,7 +145,7 @@ function produce(v)
139145 end
140146
141147 # Internal check to make sure that it is possible to switch to the consumer.
142- @assert getproperty ( task, : state) in (:runnable , :queued )
148+ @assert task. state in (:runnable , :queued )
143149
144150 @static if VERSION < v " 1.1.9999"
145151 task. state === :queued && yield ()
@@ -203,7 +209,7 @@ function consume(ctask::CTask, values...)
203209 push! (producer. storage[:consumers ]. waitq, ct)
204210 end
205211
206- if getproperty ( producer, : state) === :runnable
212+ if producer. state === :runnable
207213 # Switch to the producer.
208214 schedule (producer)
209215 yield ()
@@ -254,4 +260,3 @@ function setstate!(task::Task, state)
254260 end
255261 end
256262end
257-
0 commit comments