@threadsif

Sat, 28 Dec 2019 02:08:30 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sat, 28 Dec 2019 02:08:30 +0200
changeset 8
44ac3683263c
parent 7
900a7e18ca01
child 9
59d94d475b5a

@threadsif

src/Util.jl file | annotate | diff | comparison | revisions
--- a/src/Util.jl	Fri Dec 27 22:04:49 2019 +0200
+++ b/src/Util.jl	Sat Dec 28 02:08:30 2019 +0200
@@ -23,7 +23,21 @@
        mean,
        proj_norm₂₁ball!,
        curry,
-       ⬿
+       ⬿,
+       @threadsif
+
+
+##########
+# Threads
+##########
+
+macro threadsif(threads, loop)
+    return esc(:(if $threads
+                    Threads.@threads $loop
+                 else
+                    $loop
+                 end))
+end
 
 ########################
 # Functional programming

mercurial