Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 27th, 2012  |  syntax: None  |  size: 0.42 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * Functor instance for Future to accumulate transformations
  3.  * to be called only when Future#get is invoked.
  4.  */
  5.  
  6. implicit def FutureFunctor = new Functor[Future] {
  7.   def fmap[A, B](r: Future[A], f: A => B) = new Future[B] {
  8.     def cancel(miir: Boolean) = r.cancel(miir)
  9.     def isCancelled() = r.isCancelled()
  10.     def isDone() = r.isDone()
  11.     def get() = f(r.get())
  12.     def get(ti: Long, tu: TimeUnit) = f(r.get(ti, tu))
  13.   }
  14. }