finagle-clojure.future-pool
Functions for creating & using com.twitter.util.FuturePool. FuturePools can be used to run blocking code on a thread separate from Finagle. This allows synchronous libraries to be used asynchronously in an application using Finagle. A Future will be returned which allows for easy integration to other asynchronous Finagle code.
future-pool
(future-pool executor-service)FuturePools can be used to run synchronous code on a thread pool. Once a FuturePool has been created tasks can be run on it, a Future will be returned representing its completion.
Arguments:
executor-service: thejava.util.concurrent.ExecutorServicethat will back the returned FuturePool.
Returns:
A new ExecutorServiceFuturePool.
immediate-future-pool
(immediate-future-pool)interruptible-future-pool
(interruptible-future-pool executor-service)FuturePools can be used to run synchronous code on a thread pool. Once a FuturePool has been created tasks can be run on it, a Future will be returned representing its completion.
This function returns an InterruptibleExecutorServiceFuturePool, similar to an ExecutorServiceFuturePool but interrupts on the Futures returned by run* or run will attempt to propagate to the backing ExecutorService.
Arguments:
executor-service: thejava.util.concurrent.ExecutorServicethat will back the returned FuturePool.
Returns:
A new InterruptibleExecutorServiceFuturePool.
interruptible-unbounded-future-pool
(interruptible-unbounded-future-pool executor-service)FuturePools can be used to run synchronous code on a thread pool. Once a FuturePool has been created tasks can be run on it, a Future will be returned representing its completion.
This function will return a FuturePool backed by an unbounded, cached, thread pool. While this FuturePool may be suitable for IO concurrency, computational concurrency may require finer tuning (see interruptible-future-pool).
Interrupts on the Futures returned by run* or run will attempt to propagate to the backing thread pool.
Arguments:
executor-service: thejava.util.concurrent.ExecutorServicethat will back the returned FuturePool.
Returns:
A new InterruptibleExecutorServiceFuturePool.
run
macro
(run future-pool & body)Sugar for creating a scala.Function0 and passing it to run*. Run body on FuturePool future-pool. A Future will be returned representing the async application of body.
Arguments:
future-pool: the FuturePool on whichbodywill runbody: will execute asynchronously to relative to the current thread onfuture-pool
Returns:
A Future that will be defined when body has run. Its value will be the result of applying body, or a thrown exception.
See: run* & scala/Function0
run*
(run* future-pool fn0)Run scala.Function0 or Clojure fn fn0 on FuturePool future-pool. A Future will be returned representing the async application of fn0.
Arguments:
future-pool: the FuturePool on whichfn0will runfn0: a scala.Function0 or Clojure fn to apply asynchronously
Returns:
A Future that will be defined when fn0 has run. Its value will be the result of applying fn0, or a thrown exception.
See: scala/Function0 & run
unbounded-future-pool
(unbounded-future-pool)FuturePools can be used to run synchronous code on a thread pool. Once a FuturePool has been created tasks can be run on it, a Future will be returned representing its completion.
This function will return a FuturePool backed by an unbounded, cached, thread pool. While this FuturePool may be suitable for IO concurrency, computational concurrency may require finer tuning (see future-pool).
Returns:
A new FuturePool.