Skip to content

Commit

Permalink
simplify locking
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Oct 8, 2023
1 parent d97fb12 commit 73101f5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 88 deletions.
1 change: 0 additions & 1 deletion src/Rasters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ include("read.jl")
include("write.jl")
include("show.jl")
include("plotrecipes.jl")
include("sectorlock.jl")

include("methods/burning/edges.jl")
include("methods/burning/allocs.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/methods/burning/geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function _burn_geometry!(B::AbstractRaster, ::GI.AbstractFeatureCollectionTrait,
end
# Where geoms is an iterator
function _burn_geometry!(B::AbstractRaster, trait::Nothing, geoms;
collapse::Union{Bool,Nothing}=nothing, lock=SectorLocks(), verbose=true, progress=true, threaded=true,
collapse::Union{Bool,Nothing}=nothing, lock=Threads.SpinLock(), verbose=true, progress=true, threaded=true,
allocs=_burning_allocs(B; threaded), kw...
)::Bool
range = _geomindices(geoms)
Expand Down
6 changes: 3 additions & 3 deletions src/methods/rasterize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct Rasterizer{T,G,F,R,O,I,M}
op::O
init::I
missingval::M
lock::Union{SectorLocks,Nothing}
lock::Union{Threads.SpinLock,Nothing}
shape::Symbol
boundary::Symbol
verbose::Bool
Expand Down Expand Up @@ -138,7 +138,7 @@ function Rasterizer(geom, fill, fillitr;
@warn "currently `:points` rasterization of multiple non-`PointTrait` geometries may be innaccurate for `reducer` methods besides $stable_reductions. Make a Rasters.jl github issue if you need this to work"
end
eltype, missingval = get_eltype_missingval(eltype, missingval, fillitr, init, filename, op, reducer)
lock = threaded ? SectorLocks() : nothing
lock = threaded ? Threads.SpinLock() : nothing

return Rasterizer(eltype, geom, fillitr, reducer, op, init, missingval, lock, shape, boundary, verbose, progress, threaded)
end
Expand Down Expand Up @@ -573,7 +573,7 @@ function _rasterize!(A, ::GI.AbstractGeometryTrait, geom, fill, r::Rasterizer; a
boolmask!(bools, geom; allocs, lock, shape, boundary, verbose, progress)
hasburned = any(bools)
if hasburned
# Avoid race conditions with a SectorLock
# Avoid race conditions
isnothing(lock) || Base.lock(lock, V)
_fill!(V, bools, fill, op, init, missingval)
isnothing(lock) || Base.unlock(lock)
Expand Down
83 changes: 0 additions & 83 deletions src/sectorlock.jl

This file was deleted.

0 comments on commit 73101f5

Please sign in to comment.