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 108108const ALLOC_CACHE = ScopedValue {Union{Nothing, AllocCache}} (nothing )
109109
110110"""
111- @cached( cache, expr)
111+ @cached cache expr
112112
113113Evaluate `expr` using allocations cache `cache`.
114114
@@ -144,14 +144,17 @@ See [`@uncached`](@ref).
144144"""
145145macro cached (cache, expr)
146146 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
150153 end
151154end
152155
153156"""
154- uncached( expr)
157+ @ uncached expr
155158
156159Evaluate expression `expr` without using the allocation. This is useful to call from within
157160`@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