Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "CommonDataFormat"
uuid = "a9737db6-c05c-4e48-868b-6bc41491d9d9"
version = "0.4.2"
version = "0.4.3"
authors = ["Beforerr <zzj956959688@gmail.com> and contributors"]

[workspace]
Expand Down
17 changes: 11 additions & 6 deletions src/CommonDataFormat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@ export is_record_varying
return chnl
end
else
# First called inside `@threads`; unlocked, racing workers each build a pool and one
# deadlocks returning its decompressor to the other, already full, pool.
const _decompressors = Ref{Union{Channel{Decompressor},Nothing}}(nothing)
const _decompressors_lock = ReentrantLock()
function decompressors()
if _decompressors[] === nothing
n_ch = nthreads()
chnl = Channel{Decompressor}(n_ch)
foreach(i -> put!(chnl, Decompressor()), 1:n_ch)
_decompressors[] = chnl
@lock _decompressors_lock begin
if _decompressors[] === nothing
n_ch = nthreads()
chnl = Channel{Decompressor}(n_ch)
foreach(i -> put!(chnl, Decompressor()), 1:n_ch)
_decompressors[] = chnl
end
return _decompressors[]
end
return _decompressors[]
end
__init__() = _decompressors[] = nothing
end
Expand Down
Loading