Skip to content

Commit

Permalink
Merge c292520 into 7c2c5a2
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Oct 24, 2020
2 parents 7c2c5a2 + c292520 commit 1183449
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
1 change: 1 addition & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
environment:
JULIA_NUM_THREADS: 2
matrix:
- julia_version: 0.7
- julia_version: 1.0
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ julia:
- 1.0
- 1
- nightly
env:
- JULIA_NUM_THREADS=2
matrix:
allow_failures:
- julia: nightly
Expand Down
27 changes: 15 additions & 12 deletions src/loadsave.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const sym2loader = Dict{Symbol,Vector{Symbol}}()
const sym2saver = Dict{Symbol,Vector{Symbol}}()
const load_locker = Base.ReentrantLock()

is_installed(pkg::Symbol) = get(Pkg.installed(), string(pkg), nothing) != nothing

Expand All @@ -16,19 +17,21 @@ function topimport(modname)
end

function checked_import(pkg::Symbol)
# kludge for test suite
if isdefined(Main, pkg)
m1 = getfield(Main, pkg)
isa(m1, Module) && return m1
end
if isdefined(FileIO, pkg)
m1 = getfield(FileIO, pkg)
isa(m1, Module) && return m1
lock(load_locker) do
# kludge for test suite
if isdefined(Main, pkg)
m1 = getfield(Main, pkg)
isa(m1, Module) && return m1
end
if isdefined(FileIO, pkg)
m1 = getfield(FileIO, pkg)
isa(m1, Module) && return m1
end
m = _findmod(pkg)
m == nothing || return Base.loaded_modules[m]
topimport(pkg)
return Base.loaded_modules[_findmod(pkg)]
end
m = _findmod(pkg)
m == nothing || return Base.loaded_modules[m]
topimport(pkg)
return Base.loaded_modules[_findmod(pkg)]
end


Expand Down
7 changes: 7 additions & 0 deletions test/loadsave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ end # module Dummy
@test load(fn) == a
rm(fn)

if Threads.nthreads() > 1
Threads.@threads for i in 1:(Threads.nthreads() * 5)
fn = string(tempname(), ".dmy")
save(fn, a)
end
end

# force format
fn = string(tempname(), ".dmy")
savestreaming(format"DUMMY", fn) do writer
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ using FileIO
using FilePathsBase
using Test

Threads.nthreads() <= 1 && @info "Threads.nthreads() = $(Threads.nthreads()), multithread tests will be disabled"

# Both FileIO and FilePathsBase export filename, but we only want the FileIO definition.
using FileIO: filename

Expand Down

0 comments on commit 1183449

Please sign in to comment.