Async problem using terminator ".later" (Futures)

9 views
Skip to first unread message

Carl

unread,
May 30, 2013, 5:04:43 AM5/30/13
to twig-p...@googlegroups.com
Hi,

We need to retrieve a large amount of data from the datastore but this has proven difficult to do within an acceptable time frame. All data is independent and to speed things up it would be nice if the work could be done in parallel.

So the first thing we tried was Twig's use of Futures with the terminator ".later". However, it is not working as we expected. Could someone please provide an example or tell us where we went wrong?

Serial:

List<Object> result1 = query1.returnAll().now();

List<Object> result2 = query2.returnAll().now();



Parallel:

Future<List<Object>> future1 = query1.returnAll().later(); // Should return immediately but takes as long as ".now" in our tests

Future<List<Object>> future2 = query2.returnAll().later(); // Should return immediately but takes as long as ".now" in our tests

List<Object> result1 = future1.get()):

List<Object> result2 = future2.get()):


Should the total time of the parallel example be less than the serial one? Any other hints on how to speed this up?


Thanks for any responses,

Carl

Reply all
Reply to author
Forward
0 new messages