Slide 27
Slide 27 text
この方針に従って
waitany を分解する
異なる型が混在しない場合については、次のやり方で対応できそう。
waitany(seq; throw::Bool=true) = _waitany(eltype(seq), seq, throw)
_waitany(::Nothing, throw::Bool) = ([], [])
_waitany(::Type{T}, seq, throw::Bool) where {T} = waitany([x::T for x in seq]; throw=throw)
_waitany(::Type{Any}, seq, throw::Bool) = _waitany(peel(seq)..., throw)
_waitany(fst::T, rest::R, throw::Bool) where {T, R} = waitany(collectwaitables(fst, rest); throw=throw)
waitany(tasks::AbstractVector{Task}; throw::Bool=true) = _wait_multiple(tasks, throw)
function collectwaitables(fst::T, rest) where {T}
checkwaitable(fst) # fst の型が waitable type かチェックし、違う場合に例外を出す
waitables = [fst]
for x in rest
x isa T || error("Expected an iterator of `$(T)` object")
push!(waitables, x)
end
return waitables
end
今後の展開
2024.08.31 JuliaTokyo #12 26