Skip to content

Commit

Permalink
Remove ambigious method def
Browse files Browse the repository at this point in the history
  • Loading branch information
nHackel committed Dec 13, 2023
1 parent 8add563 commit bab42c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/AlgorithmInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ end
export process
# process(algoT::Type{T}, ...) as pure helper functions
# Overwrite process(algo, ...) to mutate struct based on helper function result
process(algoT::Type{T}, param::AbstractImageReconstructionParameters, inputs...) where {T<:AbstractImageReconstructionAlgorithm} = error("No processing defined for algorithm $T with parameter $(typeof(param))")
"""
process(algo::Union{A, Type{A}}, param::AbstractImageReconstructionParameters, inputs...) where A <: AbstractImageReconstructionAlgorithm
"""
function process end
process(algo::AbstractImageReconstructionAlgorithm, param::AbstractImageReconstructionParameters, inputs...) = process(typeof(algo), param, inputs...)

"""
Expand Down
10 changes: 1 addition & 9 deletions src/RecoPlans/Cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ Base.@kwdef mutable struct CachedProcessParameter{P <: AbstractImageReconstructi
cache::LRU{UInt64, Any} = LRU{UInt64, Any}(maxsize = maxsize)
const maxsize::Int64 = 1
end
function process(algo::AbstractImageReconstructionAlgorithm, param::CachedProcessParameter, inputs...)
id = hash(param.param, hash(inputs, hash(algo)))
result = get!(param.cache, id) do
process(algo, param.param, inputs...)
end
param.cache[id] = result
return result
end
function process(algo::Type{<:AbstractImageReconstructionAlgorithm}, param::CachedProcessParameter, inputs...)
function process(algo::Union{A, Type{<:A}}, param::CachedProcessParameter, inputs...) where {A<:AbstractImageReconstructionAlgorithm}
id = hash(param.param, hash(inputs, hash(algo)))
result = get!(param.cache, id) do
process(algo, param.param, inputs...)
Expand Down

0 comments on commit bab42c2

Please sign in to comment.