Skip to content

Commit d539e65

Browse files
authored
force finalize all transforms first in multithreaded reproject (#300)
1 parent 014ae20 commit d539e65

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ext/GeometryOpsProjExt/reproject.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ function reproject(geom, transform::Proj.Transformation;
7070
functors = TaskFunctors(WithXY.(proj_transforms))
7171
apply(functors, GI.PointTrait(), geom; kw1...)
7272
end
73-
# Destroy the temporary threading contexts that we created
73+
# First, destroy the temporary transforms we created,
74+
# so that the contexts are not destroyed while the transforms still exist
75+
# if the GC was slow.
76+
foreach(finalize, proj_transforms)
77+
# Destroy the temporary threading contexts that we created,
78+
# now that it is safe to do so.
7479
foreach(Proj.proj_context_destroy, contexts)
7580
# Return the results
7681
return results
@@ -81,4 +86,4 @@ function reproject(geom, transform::Proj.Transformation;
8186
return apply(WithXY(transform), GI.PointTrait(), geom; kw1...)
8287
end
8388
end
84-
end
89+
end

0 commit comments

Comments
 (0)