diff --git a/docs/make.jl b/docs/make.jl index 985e0ff..ebfdb3b 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -28,7 +28,7 @@ end for example in ["cholesky", "blur-roberts", "lcs", "sort"] println("\n*** Generating $example example") @time begin - dir = joinpath(DataFlowTasks.PROJECT_ROOT, "docs", "src", "examples", example) + dir = joinpath(DataFlowTasks._get_dataflowtasks_root(), "docs", "src", "examples", example) src = joinpath(dir, "$(example).jl") Literate.markdown(src, dir) draft || Literate.notebook(src, dir; preprocess = insert_setup) @@ -37,7 +37,7 @@ end # generate readme println("\n*** Generating README") -@time cd(joinpath(DataFlowTasks.PROJECT_ROOT, "docs", "src", "readme")) do +@time cd(joinpath(DataFlowTasks._get_dataflowtasks_root(), "docs", "src", "readme")) do src = joinpath(pwd(), "README.jl") # Run code diff --git a/src/DataFlowTasks.jl b/src/DataFlowTasks.jl index 69eb4b1..8f151fa 100644 --- a/src/DataFlowTasks.jl +++ b/src/DataFlowTasks.jl @@ -1,3 +1,5 @@ +__precompile__() + """ module DataFlowTask @@ -5,7 +7,12 @@ Create `Task`s which can keep track of how data flows through it. """ module DataFlowTasks -const PROJECT_ROOT = pkgdir(DataFlowTasks) +dir = pkgdir(DataFlowTasks) +@static if VERSION > v"1.8" + const PROJECT_ROOT::Ref{String} = Ref{String}(dir) +else + const PROJECT_ROOT = Ref{String}(dir) +end using OrderedCollections using Compat @@ -16,6 +23,18 @@ using Printf export @dspawn, @dasync +""" + _get_dataflowtasks_root() + +Returns the current `PROJECT_ROOT` value. + +Does not assume the ref has been set. +""" +function _get_dataflowtasks_root() + global PROJECT_ROOT + return PROJECT_ROOT[] +end + """ @enum AccessMode READ WRITE READWRITE @@ -40,6 +59,10 @@ include("dag.jl") include("taskgraph.jl") include("arrayinterface.jl") +""" + __init__() + +""" function __init__() # default scheduler capacity = 50 diff --git a/test/Project.toml b/test/Project.toml index dc3f797..749ee94 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,5 +1,6 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +DataFlowTasks = "d1549cb6-e9f4-42f8-98cc-ffc8d067ff5b" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" diff --git a/test/priorityscheduler_test.jl b/test/priorityscheduler_test.jl index 53ed9a5..7e9dc48 100644 --- a/test/priorityscheduler_test.jl +++ b/test/priorityscheduler_test.jl @@ -7,7 +7,7 @@ background = false sch = DataFlowTasks.PriorityScheduler(100, background) DataFlowTasks.setscheduler!(sch) -include(joinpath(DataFlowTasks.PROJECT_ROOT, "test", "testutils.jl")) +include(joinpath(DataFlowTasks._get_dataflowtasks_root(), "test", "testutils.jl")) @testset "Priority scheduler" begin @testset "Fork-join" begin diff --git a/test/staticscheduler_test.jl b/test/staticscheduler_test.jl index 3f797b0..0f9b1f0 100644 --- a/test/staticscheduler_test.jl +++ b/test/staticscheduler_test.jl @@ -6,7 +6,7 @@ using LinearAlgebra sch = DataFlowTasks.StaticScheduler() DataFlowTasks.setscheduler!(sch) -include(joinpath(DataFlowTasks.PROJECT_ROOT, "test", "testutils.jl")) +include(joinpath(DataFlowTasks._get_dataflowtasks_root(), "test", "testutils.jl")) @testset "Static scheduler" begin @testset "Fork-join" begin diff --git a/test/taskgraph_test.jl b/test/taskgraph_test.jl index e9faa94..13f2bff 100644 --- a/test/taskgraph_test.jl +++ b/test/taskgraph_test.jl @@ -3,7 +3,7 @@ using LinearAlgebra using DataFlowTasks import DataFlowTasks as DFT -include(joinpath(DFT.PROJECT_ROOT, "test", "testutils.jl")) +include(joinpath(DFT._get_dataflowtasks_root(), "test", "testutils.jl")) tg = DFT.TaskGraph(200) DFT.set_active_taskgraph!(tg)