Skip to content

Commit 6d072a8

Browse files
authored
Lazily init cholmod (#626)
On top of #625
2 parents 8ff11da + fac1548 commit 6d072a8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/solvers/cholmod.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,20 @@ function newcommon(; print = 0) # no printing from CHOLMOD by default
174174
end
175175

176176
function getcommon(::Type{Int32})
177+
init_once()
177178
return get!(newcommon, task_local_storage(), :cholmod_common)::Ref{cholmod_common}
178179
end
179180

180181
function getcommon(::Type{Int64})
182+
init_once()
181183
return get!(newcommon_l, task_local_storage(), :cholmod_common_l)::Ref{cholmod_common}
182184
end
183185

184186
getcommon() = getcommon(Int)
185187

186188
const BUILD_VERSION = VersionNumber(CHOLMOD_MAIN_VERSION, CHOLMOD_SUB_VERSION, CHOLMOD_SUBSUB_VERSION)
187189

188-
function __init__()
190+
const init_once = Base.OncePerProcess{Nothing}() do
189191
try
190192
### Check if the linked library is compatible with the Julia code
191193
if Libdl.dlsym_e(Libdl.dlopen("libcholmod"), :cholmod_version) != C_NULL

0 commit comments

Comments
 (0)