diff --git a/src/threadtasks.jl b/src/threadtasks.jl index 4e8c272..668ed31 100644 --- a/src/threadtasks.jl +++ b/src/threadtasks.jl @@ -71,7 +71,7 @@ end t = TASKS[tid] if istaskfailed(t) initialize_task(tid) - return true + throw(TaskFailedException(t)) end yield() false @@ -90,4 +90,3 @@ end end false end - diff --git a/test/threadingutilities.jl b/test/threadingutilities.jl index bb43d74..719e867 100644 --- a/test/threadingutilities.jl +++ b/test/threadingutilities.jl @@ -77,14 +77,18 @@ end @test ThreadingUtilities.load(pointer(x), ThreadingUtilities.ThreadState) == ThreadingUtilities.SPIN end + # Make all tasks error for tid ∈ eachindex(ThreadingUtilities.TASKS) launch_thread_copy!(tid, Float64[], Float64[]) end sleep(1) @test all(istaskfailed, ThreadingUtilities.TASKS) - @test all(ThreadingUtilities.wait, eachindex(ThreadingUtilities.TASKS)) + # Test that `wait` reports the error for each task + for tid in eachindex(ThreadingUtilities.TASKS) + @test_throws TaskFailedException ThreadingUtilities.wait(tid) + end + # Test that none of the tasks are in the failed state @test !any(istaskfailed, ThreadingUtilities.TASKS) # test copy on the reinitialized tasks foreach(test_copy, eachindex(ThreadingUtilities.TASKS)) end -