I have a function containing a for loop. I would like to add an argument to that function that lets me chose to run the loop parrallel using
Threads.@threads for i in ...
.
I thus just need to inject Threads.@threads
in front of the loop. Macros don′t work as they can′t handle keywords.
Alterntively I could have something like
if parrallel
inject("Threads.@threads for i in 1:n")
else
inject("for i in 1:n")
end
loop content....
end
I can′t find any way to insert code like that. What to do?
It would of course be an option to put the whole loop in a function and just use an if else containing the for loops over the function but I would prefer the rest of the code as is.