@@ -4,7 +4,10 @@ Base.@kwdef mutable struct ProcessResultCache{P <: AbstractImageReconstructionPa
4
4
const maxsize:: Int64 = 1
5
5
cache:: LRU{UInt64, Any} = LRU {UInt64, Any} (maxsize = maxsize)
6
6
end
7
- function process (algo:: Union{A, Type{<:A}} , param:: ProcessResultCache , inputs... ) where {A<: AbstractImageReconstructionAlgorithm }
7
+ process (algo:: A , param:: ProcessResultCache , inputs... ) where {A <: AbstractImageReconstructionAlgorithm } = hashed_process (algo, param, inputs... )
8
+ process (algoT:: Type{<:A} , param:: ProcessResultCache , inputs... ) where {A <: AbstractImageReconstructionAlgorithm } = hashed_process (algoT, param, inputs... )
9
+
10
+ function hashed_process (algo, param:: ProcessResultCache , inputs... )
8
11
id = hash (param. param, hash (inputs, hash (algo)))
9
12
result = get! (param. cache, id) do
10
13
process (algo, param. param, inputs... )
@@ -28,9 +31,14 @@ function clear!(plan::RecoPlan{<:ProcessResultCache}, preserve::Bool = true)
28
31
return plan
29
32
end
30
33
31
- function validvalue (plan, :: Type{T} , value:: RecoPlan{<:ProcessResultCache} ) where T
34
+ function validvalue (plan, union:: Type{Union{T, ProcessResultCache{<:T}}} , value:: RecoPlan{ProcessResultCache} ) where T
35
+ innertype = value. param isa RecoPlan ? typeof (value. param). parameters[1 ] : typeof (value. param)
36
+ return ProcessResultCache{<: innertype } <: union
37
+ end
38
+
39
+ function validvalue (plan, union:: UnionAll , value:: RecoPlan{ProcessResultCache} )
32
40
innertype = value. param isa RecoPlan ? typeof (value. param). parameters[1 ] : typeof (value. param)
33
- return ProcessResultCache{<: innertype } <: T
41
+ return ProcessResultCache{<: innertype } <: union
34
42
end
35
43
36
44
# Do not serialize cache and lock, only param
0 commit comments