From 189841fe2325d8f896ac9c37f47bcb400d232d85 Mon Sep 17 00:00:00 2001 From: Eric Davies Date: Tue, 11 Jun 2019 14:49:29 -0500 Subject: [PATCH 1/3] Export istaskfailed --- base/exports.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/base/exports.jl b/base/exports.jl index 2d84157686774..22b2cca2546e7 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -646,6 +646,7 @@ export islocked, istaskdone, istaskstarted, + istaskfailed, lock, notify, ReentrantLock, From 1b7c29b27412a23c6e659a65a5257e72f52430ef Mon Sep 17 00:00:00 2001 From: Eric Davies Date: Wed, 12 Jun 2019 13:44:43 -0500 Subject: [PATCH 2/3] Add docstring for istaskfailed --- base/task.jl | 22 ++++++++++++++++++++++ doc/src/base/parallel.md | 1 + 2 files changed, 23 insertions(+) diff --git a/base/task.jl b/base/task.jl index af8c2c5c302b4..71ddd551da5f4 100644 --- a/base/task.jl +++ b/base/task.jl @@ -135,6 +135,28 @@ false """ istaskstarted(t::Task) = ccall(:jl_is_task_started, Cint, (Any,), t) != 0 +""" + istaskfailed(t::Task) -> Bool + +Determine whether a task has exited because an exception was thrown. + +# Examples +```jldoctest +julia> a4() = error("task failed"); + +julia> b = Task(a4); + +julia> istaskfailed(b) +false + +julia> schedule(b); + +julia> yield(); + +julia> istaskfailed(b) +true +``` +""" istaskfailed(t::Task) = (t.state == :failed) Threads.threadid(t::Task) = Int(ccall(:jl_get_task_tid, Int16, (Any,), t)+1) diff --git a/doc/src/base/parallel.md b/doc/src/base/parallel.md index 362e6bcc977e5..453cd4562ba2c 100644 --- a/doc/src/base/parallel.md +++ b/doc/src/base/parallel.md @@ -11,6 +11,7 @@ Base.fetch(t::Task) Base.current_task Base.istaskdone Base.istaskstarted +Base.istaskfailed Base.task_local_storage(::Any) Base.task_local_storage(::Any, ::Any) Base.task_local_storage(::Function, ::Any, ::Any) From e596dc023aee3e1b300149d8044055c09871dc69 Mon Sep 17 00:00:00 2001 From: Eric Davies Date: Fri, 5 Jul 2019 11:55:00 -0500 Subject: [PATCH 3/3] Add news for istaskfailed --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 81fbdcca94bfd..f3ee8bb0abb56 100644 --- a/NEWS.md +++ b/NEWS.md @@ -25,6 +25,7 @@ New library functions * `findfirst`, `findlast`, `findnext` and `findprev` now accept a character as first argument to search for that character in a string passed as the second argument ([#31664]). * New `findall(pattern, string)` method where `pattern` is a string or regex ([#31834]). +* `istaskfailed` is now documented and exported, like its siblings `istaskdone` and `istaskstarted` ([#32300]). Standard library changes ------------------------