Yield a result from a list of Scala Future -


i brand new scala futures , working on simple task.

i have following function returns list of future , want read result (and block until future finished).

private def findall(classname: string): list[future[vector[parseobject]]]= {     def find(query: parsequery[parseobject], from: int, limit: int) = {       query.skip(from)       query.limit(limit)       future(query.find().asscala.tovector)     }      val count = parsequery.getquery(classname).count()     val skip = 1000     val fromandlimit = (from <- 0 count skip) yield (from, if (from + skip < count) skip else count - )     println("fromandlimit: " + fromandlimit)      (for((from, limit) <- fromandlimit if limit > 0) yield find(parsequery.getquery(classname), from, limit)).tolist   } 

as appears, function try read objects parse.com , return objects in 1 big vector.

(code snippet appreciated; right not trying learn future, want solution case).

if want compose futures 1 call:

val compositefuture: future[list[vector[parseobject]]] = future.sequence(findall(???)) 

if want wait completion, then:

val result: list[vector[parseobject]] = await.result(compositefuture, 1 minute) 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -