We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 08dac12 commit 008392aCopy full SHA for 008392a
src/threadsafe.jl
@@ -5,12 +5,10 @@
5
struct VectorOfLogps{T1, T2 <: Vector{Base.RefValue{T1}}}
6
v::T2
7
end
8
-VectorOfLogps(::Type{T}, n::Int) where {T} = VectorOfLogps(zero(T), n)
9
function VectorOfLogps(val::T, n::Int) where {T}
10
- v = [val for i in 1:Threads.nthreads()]
+ v = [Ref(val) for i in 1:n]
11
return VectorOfLogps(v)
12
13
-VectorOfLogps(v::Vector) = VectorOfLogps(Ref.(v))
14
Base.getindex(v::VectorOfLogps, i::Integer) = v.v[i][]
15
function Base.setindex!(v::VectorOfLogps, val, i::Integer)
16
v.v[i][] = val
0 commit comments