Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Augustus.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module Augustus

include("types.jl")
include("macros.jl")

end # module Augustus
20 changes: 20 additions & 0 deletions src/macros.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Some of the code in this file is taken from Gaius.jl (license: MIT)
# https://github.com/MasonProtter/Gaius.jl

# Note this does not support changing the number of threads at runtime

macro _spawn(ex)
if Threads.nthreads() > 1
esc(Expr(:macrocall, Expr(:(.), :Threads, QuoteNode(Symbol("@spawn"))), __source__, ex))
else
esc(ex)
end
end

macro _sync(ex)
if Threads.nthreads() > 1
esc(Expr(:macrocall, Symbol("@sync"), __source__, ex))
else
esc(ex)
end
end
Empty file added src/types.jl
Empty file.
12 changes: 12 additions & 0 deletions test/macros.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@testset "Macros" begin
a = Augustus.@_sync begin
Augustus.@_spawn begin
1 + 1
end
end
if Threads.nthreads() > 1
@test fetch(a) == 2
else
@test a == 2
end
end
3 changes: 1 addition & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ versioninfo()

@info("Running tests with $(Threads.nthreads()) threads")

@testset "Augustus.jl" begin
end
include("macros.jl")