Skip to content

Commit 68ebb1e

Browse files
committed
test mixing contexts under threading
1 parent 618aba7 commit 68ebb1e

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

test/test_geos_types.jl

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,31 @@ end
362362
g1 = LibGEOS.Polygon(p, ctx)
363363
g2 = LibGEOS.Polygon(p, ctx)
364364
for j=1:n
365-
LibGEOS.intersects(g1, g2, ctx)
365+
@test LibGEOS.intersects(g1, g2, ctx)
366366
end
367367
end
368368
GC.gc(true)
369369
return nothing
370370
end
371-
f91(91)
371+
@test f91(91) === nothing
372+
function f91_mixed_contexts(n)
373+
nthread = Threads.nthreads()
374+
contexts = [LibGEOS.GEOSContext() for i=1:nthread]
375+
p = [[[-1.,-1],[+1,-1],[+1,+1],[-1,+1],[-1,-1]]]
376+
Threads.@threads :static for i=1:n
377+
ctx1 = contexts[rand(1:nthread)]
378+
ctx2 = contexts[rand(1:nthread)]
379+
ctx3 = contexts[rand(1:nthread)]
380+
g1 = LibGEOS.Polygon(p, ctx1)
381+
g2 = LibGEOS.Polygon(p, ctx2)
382+
for j=1:n
383+
@test LibGEOS.intersects(g1, g2, ctx3)
384+
end
385+
end
386+
GC.gc(true)
387+
return nothing
388+
end
389+
@test f91_mixed_contexts(91) === nothing
372390
@testset "clone" begin
373391
function f(n)
374392
# adapted from https://github.com/JuliaGeo/LibGEOS.jl/issues/91#issuecomment-1267732709
@@ -379,13 +397,13 @@ end
379397
g1 = LibGEOS.clone(p,ctx)
380398
g2 = LibGEOS.clone(p,ctx)
381399
for j=1:n
382-
intersects(g1,g2)
400+
@test intersects(g1,g2)
383401
end
384402
end
385403
GC.gc(true)
386404
return nothing
387405
end
388-
f(91)
406+
@test f(91) === nothing
389407
end
390408
end
391409

0 commit comments

Comments
 (0)