Skip to content

Instantly share code, notes, and snippets.

@itszero
Created May 10, 2013 06:04
Show Gist options
  • Save itszero/5552680 to your computer and use it in GitHub Desktop.
Save itszero/5552680 to your computer and use it in GitHub Desktop.
// 2.1 Implement buildCar in parallel (orders in parallel)
def buildCarPar(): Future[Car] = Future.join(
Factory.newChassis(),
Factory.newWheels(),
Future.join(
Factory.newCylinder(),
Factory.newPiston()
) flatMap { case (cylinder, piston) => buildEngine(cylinder, piston) }
) map { case (chassis, wheels, engine) => Car(chassis, wheels, engine) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment