Skip to content

Commit adead5a

Browse files
committed
turn off TimerOutputs when using threads
1 parent 7f6dacd commit adead5a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/util.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,17 @@ end
373373
See [`@⌛`](@ref)
374374
"""
375375
macro show⌛(ex)
376-
quote
377-
reset_timer!(get_defaulttimer())
378-
result = $(esc(ex))
379-
show(get_defaulttimer())
380-
result
376+
if Threads.nthreads()>1
377+
# TimerOutputs is not thread-safe
378+
# https://github.com/KristofferC/TimerOutputs.jl/issues/72
379+
esc(ex)
380+
else
381+
quote
382+
reset_timer!(get_defaulttimer())
383+
result = $(esc(ex))
384+
show(get_defaulttimer())
385+
result
386+
end
381387
end
382388
end
383389

0 commit comments

Comments
 (0)