Skip to content

Commit b4e652f

Browse files
committed
Don't use MacroTools for macro mt_out_of_order
MacroTools turns `(a[i] = b;)` into `a[i] = b`. We don't want that in @mt_out_of_order, since the user's intent would be to run `(a[i] = b;)` in parallel, not just `b`.
1 parent 4c2c9c0 commit b4e652f

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.4.1"
44

55
[deps]
66
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
7-
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
87

98
[compat]
109
MacroTools = "0.5"

src/ParallelProcessingTools.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ module ParallelProcessingTools
77
using Base.Threads
88
using Distributed
99

10-
using MacroTools
11-
1210
include("threadsafe.jl")
1311
include("threadlocal.jl")
1412
include("onthreads.jl")

src/onthreads.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ end
225225
export @mt_async
226226

227227

228-
using MacroTools
229228
"""
230229
@mt_out_of_order begin expr... end
231230
@@ -254,8 +253,9 @@ macro mt_out_of_order(ex)
254253
tasks = gensym(:tasks)
255254
handle_results = Vector{Expr}()
256255
for i in idxs
257-
trg = nothing; val = nothing;
258-
if @capture(exprs[i], trg_ = val_)
256+
if exprs[i] isa Expr && exprs[i].head == :(=)
257+
trg = exprs[i].args[1]
258+
val = exprs[i].args[2]
259259
if val isa Expr
260260
exprs[i] = :(push!($tasks, @mt_async($(esc(val)))))
261261
push!(handle_results, :($(esc(trg)) = fetch(popfirst!($tasks))))

0 commit comments

Comments
 (0)