Skip to content

Commit 916606d

Browse files
committed
better names and docs
1 parent 1984b60 commit 916606d

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

page/codegen.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ These are all exported when you do `using SymbolicUtils.Code`
3333

3434
{{doc Func Func type Code}}
3535

36+
{{doc SpawnFetch SpawnFetch type Code}}
37+
3638
{{doc SetArray SetArray type Code}}
3739

3840
{{doc MakeArray MakeArray type Code}}

src/code.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using StaticArrays, LabelledArrays, SparseArrays
44

55
export toexpr, Assignment, (), Let, Func, DestructuredArgs, LiteralExpr,
66
SetArray, MakeArray, MakeSparseArray, MakeTuple, AtIndex,
7-
Par, Multithreaded
7+
SpawnFetch, Multithreaded
88

99
import ..SymbolicUtils
1010
import SymbolicUtils: @matchable, Sym, Term, istree, operation, arguments
@@ -464,15 +464,21 @@ end
464464

465465
struct Multithreaded end
466466
"""
467-
Par(exprs, reduce)
467+
SpawnFetch{ParallelType}(exprs, reduce)
468468
469+
Run every expr in `exprs` in its own task, and use the `reduce`
470+
function to combine the results of executing `exprs`.
471+
472+
`ParallelType` can be used to define more parallelism types
473+
SymbolicUtils supports `Multithreaded` type. Which spawns
474+
threaded tasks.
469475
"""
470-
struct Par{Typ}
476+
struct SpawnFetch{Typ}
471477
exprs::Vector
472478
combine
473479
end
474480

475-
function toexpr(p::Par{Multithreaded}, st)
481+
function toexpr(p::SpawnFetch{Multithreaded}, st)
476482
spawns = map(p.exprs) do thunk
477483
:(Base.Threads.@spawn $(toexpr(thunk, st)))
478484
end

test/code.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ test_repr(a, b) = @test repr(Base.remove_linenums!(a)) == repr(Base.remove_linen
124124
test_repr(toexpr(MakeTuple((a, b, a+b))),
125125
:((a,b,$(+)(a,b))))
126126

127-
@test Par{Multithreaded}([1,2],vcat)|>toexpr|>eval == [1,2]
128-
@test @elapsed(Par{Multithreaded}([:(sleep(.3)),:(sleep(.6))],vcat)|>toexpr|>eval) < 0.8
127+
@test SpawnFetch{Multithreaded}([1,2],vcat)|>toexpr|>eval == [1,2]
128+
@test @elapsed(SpawnFetch{Multithreaded}([:(sleep(.3)),:(sleep(.6))],vcat)|>toexpr|>eval) < 0.8
129129
end
130130

0 commit comments

Comments
 (0)