LRUCache.jl icon indicating copy to clipboard operation
LRUCache.jl copied to clipboard

Allow the use `ReentrantLock` instead of `SpinLock`

Open gbrgr opened this issue 1 year ago • 6 comments

In the current implementation, if a user needs to hold the cache's lock over multiple gets/sets, one cannot use the cache's internal lock since it is a SpinLock and blocks.

Suggestion: Use a ReentrantLock or provide the user the option to use such a lock instead of a SpinLock. Moreover, implement

Base.lock(lru::LRU) = lock(lru.lock)

(likewise for unlock) to allow users taking that lock.

gbrgr avatar Jul 05 '23 11:07 gbrgr