scala/scala — pull request #856 by havocp (2012-07-09 17:10:51+00:00)
Title: Collection of updates to SIP-14 (scala.concurrent)

Developed by Viktor Klang and Havoc Pennington

- add Promise.isCompleted

- add Future.successful and Future.failed

- add ExecutionContextExecutor and ExecutionContextExecutorService for Java interop

- remove defaultExecutionContext as default parameter value from promise and future

- add ExecutionContext.Implicits.global which must be explicitly imported, rather
than the previous always-available value for the implicit EC

- remove currentExecutionContext, since it could create bugs by being
out of sync with the implicit ExecutionContext

- remove Future task batching (_taskStack) and Future.releaseStack

This optimization should instead be implemented either in
a specific thread pool or in a specific ExecutionContext.
Some pools or ExecutionContexts may not want or need it.
In this patch, the defaultExecutionContext does not
keep the batching optimization. Whether it should
have it should perhaps be determined through benchmarking.

- move internalBlockingCall to BlockContext and remove currentExecutionContext

In this patch, BlockContext must be implemented by Thread.currentThread,
so the thread pool is the only place you can add custom hooks
to be run when blocking.
We implement BlockContext for the default ForkJoinWorkerThread in terms of
ForkJoinPool.ManagedBlocker.

- add public BlockContext.current and BlockContext.push

These allow an ExecutionContext or other code to override
the BlockContext for the current thread. With this
API, the BlockContext is customizable without
creating a new pool of threads.

BlockContext.current is needed to obtain the previous
BlockContext before you push, so you can "chain up" to
it if desired.

BlockContext.push is used to override the context
for a given piece of code.

- move isFutureThrowable into impl.Future

- add implicitNotFound to ExecutionContext

- remove default global EC from future {} and promise {}

- add ExecutionContext.global for explicit use of the global default EC,
replaces defaultExecutionContext

- add a timeout to scala-concurrent-tck tests that block on SyncVar
(so tests time out rather than hang)

- insert blocking{} calls into concurrent tck to fix deadlocking

- add NonFatal.apply and tests for NonFatal

- add OnCompleteRunnable marker trait

This would allow an ExecutionContext to distinguish a Runnable originating
from Future.onComplete (all callbacks on Future end up going through
onComplete).

- rename ListenerRunnable to CallbackRunnable and use for KeptPromise too
Just adds some clarity and consistency.