Given an instance of a Celluloid Actor, you can use future
to execute an Actor method asynchronously and at some later point in time use the Future's value
method to obtain the result of the Actor method (blocking if necessary).
Let's say that I have two separate components in a system that both want to use the same Actor method, perhaps a very expensive database query. If both of these components individually called actor.future.expensive_query
, then the query would be executed twice and each caller would get their own separate Future object back to retrieve the results. Furthermore, the two queries would be executed serially, not concurrently. What if, instead, I wanted to have the second call to actor.future.expensive_query
to just get a reference to the Future object created by the first caller? Is such a thing possible with Celluloid?