Skip to content

Instantly share code, notes, and snippets.

@agibralter
Created April 4, 2009 04:45
Show Gist options
  • Save agibralter/90115 to your computer and use it in GitHub Desktop.
Save agibralter/90115 to your computer and use it in GitHub Desktop.
val ids = List(1, 2, 3)
ids.foreach { id =>
actor {
receiver ! getAvgSigFor(pool, id)
}
}
val sigs = getAvgSigsFor(ids)
def getAvgSigsFor(ids : List[Int]) : List[Double] = {
ids.foldLeft(List[Double]()) { (memo, id) =>
receiveWithin(60000) {
case (sig : Double) =>
memo ++ List(sig)
}
}
}
def getAvgSigFor(pool : DataSource, id : Int) : Double = {
val conn = pool.getConnection
// ...
avg_sig
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment