You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had an unpleasant experience using some multithreaded code that was writing into a BitArray that had been constructed using similar on another array that was the result of broadcasting:
It has been documented that setindex!(::BitArray, ...) is not thread-safe. However, BitArray arises whenever broadcasting produces an array with eltype(array) == Bool, and so I think it is easy to not be aware of this issue. Personally, I have an easy time being suspicious of BitArray in threaded code, even without the explicit warning. Yet it still did not initially occur to me that I should look for a BitArray when I was experiencing a race condition. I did not even remember that there were BitArray values in my code.
Some ideas that may have helped me in this case:
Broadcasting never produces BitArrays (I was originally going to title this issue "consider Array{Bool} in place of BitArray for broadcasting result")
Or, it produces some read-only version of BitArray.
similar returns Array{Bool} even for BitArray input
Or it has an extra argument to return an array of a type that is "more" thread safe.
I had an unpleasant experience using some multithreaded code that was writing into a
BitArray
that had been constructed usingsimilar
on another array that was the result of broadcasting:It has been documented that
setindex!(::BitArray, ...)
is not thread-safe. However,BitArray
arises whenever broadcasting produces an array witheltype(array) == Bool
, and so I think it is easy to not be aware of this issue. Personally, I have an easy time being suspicious ofBitArray
in threaded code, even without the explicit warning. Yet it still did not initially occur to me that I should look for aBitArray
when I was experiencing a race condition. I did not even remember that there wereBitArray
values in my code.Some ideas that may have helped me in this case:
BitArray
s (I was originally going to title this issue "considerArray{Bool}
in place ofBitArray
for broadcasting result")Or, it produces some read-only version of
BitArray
.similar
returnsArray{Bool}
even forBitArray
inputOr it has an extra argument to return an array of a type that is "more" thread safe.
And users can use it to define generic code, or it could be checked automatically by a macro that does threading.
(related https://github.com/JuliaArrays/ArrayInterface.jl)
The text was updated successfully, but these errors were encountered: