Writing cache for long running computation #1010
-
Hi, first of all thanks for the great gem! Now I know this is hinted at in the docs but I was looking for examples, the problem is - I'm writing a cache for long running computation based on Concurrent::Map and I want to make sure only single thread runs the computation in case the value is absent (with other threads waiting for result from this single thread), is it possible using just the Concurrent::Map (as far as I can tell it isn't), and if not what primitives are the best/most robust to choose? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Ok, seems like I misunderstood the docs somewhat, is there any place I can read up on the definition of "atomic"? |
Beta Was this translation helpful? Give feedback.
It took me a long while to become familiar with the library 🤗
Concurrent Ruby borrows quite a lot from Java's concurrency primitives. You might start there: https://docs.oracle.com/javase/tutorial/essential/concurrency/atomic.html