Creates a thread-safe memoized version of the receiver function.
A function that safely caches results across multiple threads.
The input type for the function.
The output type of the function.