Revision f759bc34cb43e3cd7b941616ae819d26cab54265 authored by Stefan Karpinski on 05 February 2019, 16:34:17 UTC, committed by GitHub on 05 February 2019, 16:34:17 UTC
This was unintentionally made public by the great `_length` rename:

e99191a667e2a14c34186f54faed4e474943796c

Arrays and strings were using the `_length` name for private stuff
in different ways and the refactor made this part of the `length`
API when it should have remained private. Fortunately, it's not
documented and it seems unlikely that anyone is using it.

Also rename `next_continued` to `iterate_continued` to match the
name of the method that it's continuing.
1 parent 9f66185
Raw File
threads.jl
# This file is a part of Julia. License is MIT: https://julialang.org/license

"""
Experimental multithreading support.
"""
module Threads

global Condition # we'll define this later, make sure we don't import Base.Condition

include("threadingconstructs.jl")
include("atomics.jl")
include("locks-mt.jl")


"""
    resize_nthreads!(A, copyvalue=A[1])

Resize the array `A` to length [`nthreads()`](@ref).   Any new
elements that are allocated are initialized to `deepcopy(copyvalue)`,
where `copyvalue` defaults to `A[1]`.

This is typically used to allocate per-thread variables, and
should be called in `__init__` if `A` is a global constant.
"""
function resize_nthreads!(A::AbstractVector, copyvalue=A[1])
    nthr = nthreads()
    nold = length(A)
    resize!(A, nthr)
    for i = nold+1:nthr
        A[i] = deepcopy(copyvalue)
    end
    return A
end

end
back to top