File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 108
108
const ALLOC_CACHE = ScopedValue {Union{Nothing, AllocCache}} (nothing )
109
109
110
110
"""
111
- @cached( cache, expr)
111
+ @cached cache expr
112
112
113
113
Evaluate `expr` using allocations cache `cache`.
114
114
@@ -144,14 +144,17 @@ See [`@uncached`](@ref).
144
144
"""
145
145
macro cached (cache, expr)
146
146
return quote
147
- res = @with $ (esc (ALLOC_CACHE)) => $ (esc (cache)) $ (esc (expr))
148
- free_busy! ($ (esc (cache)))
149
- res
147
+ cache = $ (esc (cache))
148
+ GC. @preserve cache begin
149
+ res = @with $ (esc (ALLOC_CACHE)) => cache $ (esc (expr))
150
+ free_busy! (cache)
151
+ res
152
+ end
150
153
end
151
154
end
152
155
153
156
"""
154
- uncached( expr)
157
+ @ uncached expr
155
158
156
159
Evaluate expression `expr` without using the allocation. This is useful to call from within
157
160
`@cached` to avoid caching some allocations, e.g., because they can be returned out of the
You can’t perform that action at this time.
0 commit comments