Open krishvishal opened 3 years ago
Nice! Didn't know about it. I think that should work for memoized top-level functions. At least, it will if the answer to this is yes (which I think it is, just wanting to verify).
I don't think it will currently work for memoized callables/closures though, since looking up the right cache itself is still happening with the non-threadsafe Memoization.cache :: IdDict
. To make those threadsafe, I need to add some locking to this package (I don't think we could use ThreadsafeDict
there, since the underlying thing needs to be an IdDict
, which that doesn't seem to support yet). If this is important to you now, I'm happy to take a PR if you can show the performance hit is not too bad. Otherwise I will play around with this myself at some point in the future.
Well, the answer wasn't exactly yes but it should still work,
using ThreadSafeDicts, Memoization
@memoize ThreadSafeDict foo(x) = ...
Can the following library be used to make Memoization.jl threadsafe?
ThreadSafe Dict: https://github.com/wherrera10/ThreadSafeDicts.jl