def apply[T](body: =>T)(implicit executor: ExecutionContext): scala.concurrent.Future[T] = {
val runnable = new PromiseCompletingRunnable(body)
executor.prepare.execute(runnable)
runnable.promise.future
}
No change = No chance ..... or course ......
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Victor,the main focus of our problem is, that it is impossible to "inject" a custom Runnable to the apply(...) method of the impl.Future.
- plug in a "mightier" esecution context.- the behavior of scala.concurrent.impl.Future to allow custom Runnables or insteadWe need a clean way to extendThis PromiseCompletingRunnable (as a Runnable) is fine for certain situations,
Especially our problem comes to evidence, when we try to implementaiton a custom remote execution context...... without a chance, since the Runnable creation stays behind the scenes and is by no way influencable.
private[concurrent] object Future {
class PromiseCompletingRunnable[T](body: => T) extends Runnable {
val promise = new Promise.DefaultPromise[T]()
override def run() = {
promise complete {
try Success(body) catch { case NonFatal(e) => Failure(e) }
}
}
}
def apply[T](body: =>T)(implicit executor: ExecutionContext): scala.concurrent.Future[T] = {
val runnable = new PromiseCompletingRunnable(body)
executor.prepare.execute(runnable)
runnable.promise.future
}
}
Hi Voctor,
sorry, but I have to be very pickyprivate[concurrent] object Future {
class PromiseCompletingRunnable[T](body: => T) extends Runnable {
val promise = new Promise.DefaultPromise[T]()
override def run() = {
promise complete {
try Success(body) catch { case NonFatal(e) => Failure(e) }
}
}
}
def apply[T](body: =>T)(implicit executor: ExecutionContext): scala.concurrent.Future[T] = {
val runnable = new PromiseCompletingRunnable(body)
executor.prepare.execute(runnable)
runnable.promise.future
}
}That is the excerpt from Future.apply(...) .....=> With the given implementation of Future.apply(..), there is no chance to exchange the Runnable by a custom Ruannable except writng a custom XYFuture implementation, right!?
==> With the given implementation of Future ..... couldn't we introduce a custom Runnable more lightweight?
===> Changing the implementation of ExecutionContet is for a**, if the Runnable is constructed independently ....
What do you think?
... as long as I do not call you "Captain Future" by mistake ;)Hi Viktor,sorry for the misspelling(s)!
Okay, back to business.Yesterday I was somehow really imprecise. Sorry for that.
Referring to the code, it will hopefulle become evident what I want:The current problem is the implementation of concurrent.Future.apply( ... )
def apply[T](body: =>T)(implicit @deprecatedName('execctx) executor: ExecutionContext): Future[T] = impl.Future(body)It calls the impl.Future(body) which is
def apply[T](body: =>T)(implicit executor: ExecutionContext): scala.concurrent.Future[T] = {
val runnable = new PromiseCompletingRunnable(body)
executor.prepare.execute(runnable)