If 2 parallel threads simultaneously make an expensive call to a
memoized function with arguments for which the returned value wasn's
cached before, 2 calls are effectively made in parallel.
It's better to avoid such a situation and if one thread already
initiated an expensive call, block on it in another thread and once
the call in the first thread is completed, unblock and reuse the value
which is cached now.
Reviewed: https:/ /review. fuel-infra. org/34808
Submitter: Pkgs Jenkins <email address hidden>
Branch: mcp/ocata
Commit: 7d03f243c68c9c1 052bcb8f7dba17f 240e930b4d
Author: Timur Sufiev <email address hidden>
Date: Wed Apr 26 16:22:51 2017
Make @memoize thread-aware
If 2 parallel threads simultaneously make an expensive call to a
memoized function with arguments for which the returned value wasn's
cached before, 2 calls are effectively made in parallel.
It's better to avoid such a situation and if one thread already
initiated an expensive call, block on it in another thread and once
the call in the first thread is completed, unblock and reuse the value
which is cached now.
Partial-Bug: #1593456 bdc9ad059d1d08d 2f457e7f492
Change-Id: I99c6d4eac5cce7