From 270cebee5eb5bb9ca2cb7aaffa96470dd0de6561 Mon Sep 17 00:00:00 2001 From: Jonas Schumacher Date: Mon, 24 Jun 2024 10:15:36 +0200 Subject: [PATCH] Fix all ambiguities except deprecations --- Project.toml | 2 ++ src/logqpool.jl | 4 ++-- src/logs.jl | 6 +++--- src/qpool.jl | 4 ++-- test/Project.toml | 1 + test/runtests_exec.jl | 1 + test/testaqua.jl | 12 ++++++++++++ 7 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 test/testaqua.jl diff --git a/Project.toml b/Project.toml index b2f45ed..6c6ad6a 100644 --- a/Project.toml +++ b/Project.toml @@ -9,5 +9,7 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] +Printf = "1" RecipesBase = "1.0" +Statistics = "1" julia = "^1.3" diff --git a/src/logqpool.jl b/src/logqpool.jl index 0c36a8f..0381585 100644 --- a/src/logqpool.jl +++ b/src/logqpool.jl @@ -96,8 +96,8 @@ end Creates a task that runs `fn(args...)` and adds it to the pool, blocking until the pool has an available thread. """ -Base.put!(pool::LoggedQueuePool, fn, args...) = Base.put!(pool, Task(()->fn(args...))) -Base.put!(fn, pool::LoggedQueuePool, args...) = Base.put!(pool, Task(()->fn(args...))) +Base.put!(pool::LoggedQueuePool, fn::T, args...) where {T <: Function} = Base.put!(pool, Task(()->fn(args...))) +Base.put!(fn::T, pool::LoggedQueuePool, args...) where {T <: Function} = Base.put!(pool, Task(()->fn(args...))) """ diff --git a/src/logs.jl b/src/logs.jl index babb03e..b5b3e1c 100644 --- a/src/logs.jl +++ b/src/logs.jl @@ -163,7 +163,7 @@ object, or a filename to be opened and read. `dt` is the time step for each row, `t0` is the optional starting time, `t1` the optional stopping time, and `nthreads` is the number of threads to print. """ -function showactivity(io, log::ThreadLog, dt, t0=0, t1=Inf; nthreads=0) +function showactivity(io::IO, log::ThreadLog, dt, t0=0, t1=Inf; nthreads=0) maxj = maximum(j.id for jobs in values(log) for j in jobs) width = length(string(maxj)) + 3 @@ -188,10 +188,10 @@ function showactivity(io, log::ThreadLog, dt, t0=0, t1=Inf; nthreads=0) end end -showactivity(io, fname::String, dt, t0=0, t1=Inf; nthreads=0) = showactivity(io, readlog(fname), dt, t0, t1; nthreads=nthreads) +showactivity(io::IO, fname::String, dt, t0=0, t1=Inf; nthreads=0) = showactivity(io, readlog(fname), dt, t0, t1; nthreads=nthreads) showactivity(log::ThreadLog, dt, t0=0, t1=Inf; nthreads=0) = showactivity(Base.stdout, log, dt, t0, t1; nthreads=nthreads) showactivity(fname::String, dt, t0=0, t1=Inf; nthreads=0) = showactivity(Base.stdout, readlog(fname), dt, t0, t1; nthreads=nthreads) -showactivity(io, pool::AbstractThreadPool, dt, t0=0, t1=Inf; nthreads=0) = showactivity(io, pool.log, dt, t0, t1; nthreads=nthreads) +showactivity(io::IO, pool::AbstractThreadPool, dt, t0=0, t1=Inf; nthreads=0) = showactivity(io, pool.log, dt, t0, t1; nthreads=nthreads) showactivity(pool::AbstractThreadPool, dt, t0=0, t1=Inf; nthreads=0) = showactivity(Base.stdout, pool.log, dt, t0, t1; nthreads=nthreads) diff --git a/src/qpool.jl b/src/qpool.jl index a1b53b9..c151191 100644 --- a/src/qpool.jl +++ b/src/qpool.jl @@ -83,8 +83,8 @@ end Creates a task that runs `fn(args...)` and adds it to the pool, blocking until the pool has an available thread. """ -Base.put!(pool::QueuePool, fn, args...) = Base.put!(pool, Task(()->fn(args...))) -Base.put!(fn, pool::QueuePool, args...) = Base.put!(pool, Task(()->fn(args...))) +Base.put!(pool::QueuePool, fn::T, args...) where {T <: Function} = Base.put!(pool, Task(()->fn(args...))) +Base.put!(fn::T, pool::QueuePool, args...) where {T <: Function} = Base.put!(pool, Task(()->fn(args...))) """ diff --git a/test/Project.toml b/test/Project.toml index 6924127..29d0b7b 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,4 +1,5 @@ [deps] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" diff --git a/test/runtests_exec.jl b/test/runtests_exec.jl index 575837d..863a9de 100644 --- a/test/runtests_exec.jl +++ b/test/runtests_exec.jl @@ -1,4 +1,5 @@ using Test, ThreadPools +include("testaqua.jl") include("teststatic.jl") include("testlogstatic.jl") include("testq.jl") diff --git a/test/testaqua.jl b/test/testaqua.jl new file mode 100644 index 0000000..7cf7495 --- /dev/null +++ b/test/testaqua.jl @@ -0,0 +1,12 @@ +module TestAqua + +using Test +using ThreadPools +using Aqua + + +@testset "Aqua" begin + Aqua.test_all(ThreadPools) +end + +end # module \ No newline at end of file