Skip to content

Commit 56823cd

Browse files
Merge pull request #158 from PhilipFackler/precompiled-optional-threads
Fixed `@maybe_threaded` to work as intended with precompilation
2 parents 80e57c2 + 2e43535 commit 56823cd

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/helper.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11

2-
macro maybe_threaded(ex)
3-
if Threads.nthreads() == 1
4-
return esc(ex)
5-
else
6-
return esc(:(Threads.@threads :static $ex))
2+
function _maybe_threaded(ex)
3+
quote
4+
if Threads.nthreads() == 1
5+
$ex
6+
else
7+
Threads.@threads :static $ex
8+
end
79
end
810
end
11+
12+
macro maybe_threaded(ex)
13+
esc(_maybe_threaded(ex))
14+
end

0 commit comments

Comments
 (0)