summaryrefslogtreecommitdiff
path: root/test/files/jvm/future-spec/FutureTests.scala
Commit message (Collapse)AuthorAgeFilesLines
* Merge commit 'cc6fea6' into merge/2.11.x-to-2.12.x-20160203Jason Zaugg2016-02-041-1/+1
|\ | | | | | | | | | | Conflicts: build.sbt scripts/jobs/integrate/bootstrap
* | Remove further references to forkjoinJason Zaugg2015-07-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use j.u.c.Forkjoin directly in active and disabled tests Remove bitrotted benchmarks code I was going to update these to use `java.util.concurrent.ForkJoin` directly, instead of our deprecated stubs. But most of them don't compile anymore (e.g. scala.testing.Benchmark has been removed, ClassTag imports missing). While I'm all for benchmarks, we should have large swathes of code checked in that isn't at compiled and run automatically. I'm happy to help someone resurrect these in a suitable form.
* | Add missing canonical combinators:Viktor Klang2014-10-201-0/+273
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - `def transform[S](f: Try[T] => Try[S])(implicit executor: ExecutionContext): Future[S]` - `def transformWith[S](f: Try[T] => Future[S])(implicit executor: ExecutionContext): Future[S]` - `def flatten[S](implicit ev: T <:< Future[S]): Future[S]` - `def zipWith[U, R](that: Future[U])(f: (T, U) => R)(implicit executor: ExecutionContext): Future[R]` Add missing utilities: - `val unit: Future[Unit]` in `object Future` - `object never extends Future[Nothing]` in `object Future` - `def defaultBlockContext: BlockContext` in `object BlockContext` - `def toString: String` on stdlib implementations of `Future` Refactors: - the `scala.concurrent.Future` trait to not explicit create any `Promises`, so that implementations can control implementation type, this is mainly facilitated through adding of the `transform` and `transformWith` methods. - the implementation of `ExecutionContextImpl` has been cleaned up - the `scala.concurrent.impl.DefaultPromise` has been reimplemented to not use `sun.misc.Unsafe` Securing: - Add a self-check in `completeWith` and `tryCompleteWith` to avoid cycles in trait Promise - Capping the maximum number of threads for the global `ExecutionContext` to the max parallelism - Implementing (almost) all `Future` combinators on `transformWith` and `transform` means that `DefaultPromise` linking works on both `(flat)map` and `recover(With)` - Nested `blocking {}` should not spawn extra threads beyond the first. Removes: - the private `internalExecutor` method in favor of an import in trait `Future` - the private `internalExecutor` method in favor of an import in trait `Promise` - the `AtomicReferenceFieldUpdater` in `AbstractPromise` since we're using `Unsafe` - `scala.concurrent.impl.Future` is no longer needed Deprecates: - `Future.onSuccess` - discourage the use of callbacks (and is also redundant considering `foreach` and `onComplete`) - `Future.onFailure` - discourage the use of callbacks (and is also redundant considering `onComplete` and `failed.foreach`) - `ExecutionContext.prepare` - it was ill specced and it is too easy to forget to call it (or even know when to call it or call it more times than needed) - All classes in scala.concurrent.forkjoin. Scala 2.12 will be Java 8+ and as such the jsr166e should be used as included in java.util.concurrent. Reimplements: - `failed` - in terms of `transform` - `map` - in terms of `transform` - `flatMap` - in terms of `transformWith` - `recover` - in terms of `transform` - `recoverWith` - in terms of `transformWith` - `zip` - in terms of `flatMap` + `map` - `fallbackTo` - in terms of `recoverWith` + `recoverWith` - `andThen` - in terms of `transform` Miscellaneous: - Giving the threads of `ExecutionContext.global` sensible names - Optimizes `object Future.successful` and `object Future.failed` are now separate implementations, to optimize for the result, avoiding doing work for the "other branch". - Optimizes `compressedRoot()` by avoiding double-calls to volatile get. Documentation: - Almost all methods on `Future` and `Promise` have been revisited and had their ScalaDoc updated Tests: - Yes
* SI-8035 Deprecate automatic () insertion in argument listsSimon Ochsenreither2014-01-091-7/+2
| | | | | | | | | | | | | This promotes the () insertion warning from -Ywarn-adapted-args to a deprecation warning. -Xfuture tunrs it into a compiler error. Auto tupling remains unchanged for now. The tests have been fixed the following way: - Warnings caused by general sloppiness (Try(), Future(), ...) have been fixed. - Warnings which raise interesting questions (x == (), ...) received an updated checkfile for now.
* SI-7958 Deprecate methods `future` and `promise` in the `scala.concurrent` ↵Philipp Haller2013-11-121-23/+23
| | | | | | | | | | | | | package object - The corresponding `apply` methods in the `Future` and `Promise` objects should be used instead. - Adjusted tests to use non-deprecated versions - Fixed doc comments not to use deprecated methods - Added comment about planned removal in 2.13.0
* Make future-spec tests not spawn threads in constructors.James Iry2013-11-011-1/+1
| | | | | | | | | The future-spec tests were spawning threads in object constructors which meant they were on the ragged edge of entering deadlock from the static initialization lock acquired during the static initialization blocks we use to construct object reference fields. My work on restructuring lambdas pushed it over the edge. This commit refactors the tests to use class constructors rather than object constructors.
* Cull extraneous whitespace.Paul Phillips2013-09-181-89/+89
| | | | | | | | | | | | | | | | | | | | | One last flurry with the broom before I leave you slobs to code in your own filth. Eliminated all the trailing whitespace I could manage, with special prejudice reserved for the test cases which depended on the preservation of trailing whitespace. Was reminded I cannot figure out how to eliminate the trailing space on the "scala> " prompt in repl transcripts. At least reduced the number of such empty prompts by trimming transcript code on the way in. Routed ConsoleReporter's "printMessage" through a trailing whitespace stripping method which might help futureproof against the future of whitespace diseases. Deleted the up-to-40 lines of trailing whitespace found in various library files. It seems like only yesterday we performed whitespace surgery on the whole repo. Clearly it doesn't stick very well. I suggest it would work better to enforce a few requirements on the way in.
* Merge v2.10.1-326-g4f8c306' into merge/v2.10.1-326-g4f8c306-to-masterJason Zaugg2013-05-171-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ================================================================ Merge commit 'v2.10.1-326-g4f8c306' into merge/v2.10.1-326-g4f8c306-to-master Conflicts: src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala src/reflect/scala/reflect/runtime/JavaMirrors.scala ================================================================ Merge -s ours 4e64a27 ([nomaster commit range]) ================================================================ Merge commit '0ae7e55' into merge/v2.10.1-326-g4f8c306-to-master Conflicts: src/compiler/scala/tools/nsc/typechecker/Macros.scala
| * SI-7164 - Removing NotImplementedError as Fatal from s.u.c.NonFatalViktor Klang2013-02-211-1/+1
| |
* | SI-7383 - Call ExecutionContext.prepare in Future.apply to allow for ↵Viktor Klang2013-05-101-0/+19
|/ | | | capturing local context like ThreadLocals and then re-establishing them prior to execution, as per intention of EC.prepare
* SI-7029 - Make test more robustPhilipp Haller2013-02-011-24/+12
|
* SI-7029 - Makes sure that uncaught exceptions are propagated to the UEH for ↵Viktor Klang2013-01-311-0/+24
| | | | the global ExecutionContext
* move Duration (incl. DSL) into scala.concurrent.duration packageRoland2012-09-191-2/+2
| | | | | | | | | so that the full package can be imported naturally: import scala.concurrent.duration._ will give you all the types (Duration, FiniteDuration, Deadline) and the DSL for constructing these.
* Basing Futures on Try instead of EitherHeather Miller2012-08-041-9/+10
|
* Critical bugfixes/leak fixes/API corrections + ScalaDoc for SIP-14Viktor Klang2012-07-191-0/+6
|
* Collection of updates to SIP-14 (scala.concurrent)Havoc Pennington2012-07-091-60/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.withBlockContext 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.withBlockContext 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.
* SIP-14: clean ups and fixesphaller2012-05-171-1/+1
|
* Widen types in signatures of Future companion methods, refactor ↵Aleksandar Prokopec2012-05-011-238/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | OnceCanBuildFrom. Removed the implicit modifier on the OnceCanBuildFrom, as we don't support implicit classes with zero arguments. Added an implicit OnceCanBuildFrom method. The idea behind OnceCanBuildFrom is for it to be used by methods which construct collections, but are defined outside of collection classes. OnceCanBuildFrom so far worked only for objects of type TraversableOnce: shuffle(List(1, 2, 3).iterator: TraversableOnce[Int]) but this used to result in an implicit resolution error: shuffle(List(1, 2, 3).iterator) because after the type parameter M for `shuffle` was inferred to Iterator, no implicit of type CanBuildFrom[Iterator[_], A, Iterator[A]] could be found. Introduced another CanBuildFrom to the Iterator companion object. Modified Future tests appropriately.
* Add promises tests.Aleksandar Prokopec2012-04-301-0/+226
|
* Fixed a bug with setting execution contexts.Aleksandar Prokopec2012-04-301-2/+138
| | | | Ported most of the future tests.
* Porting akka future tests.Aleksandar Prokopec2012-04-271-0/+364
Fixed a bug in Future.zip.