|
1 |
| -# Scala Parallel Collections |
| 1 | +# Scala parallel collections |
2 | 2 |
|
3 |
| -This Scala standard library module contains the package `scala.collection.parallel` with all parallel collections that |
4 |
| -used to be part of `scala-library` before Scala 2.13. |
| 3 | +This Scala standard module contains the package |
| 4 | +`scala.collection.parallel`, with all of the parallel collections that |
| 5 | +used to be part of the Scala standard library. |
| 6 | + |
| 7 | +As of Scala 2.13.0-M1, this module is a separate JAR that can be |
| 8 | +omitted from projects that do not use parallel collections. |
| 9 | + |
| 10 | +## Maintenance status |
| 11 | + |
| 12 | +This module is maintained by the Scala team at Lightbend. If you are |
| 13 | +interested in participating, please jump right in on issues and pull |
| 14 | +requests. |
| 15 | + |
| 16 | +Modest, targeted improvements to the existing codebase are welcome at |
| 17 | +any time. More fundamental or sweeping changes should probably wait |
| 18 | +until after the |
| 19 | +[Scala 2.13 collections rework](http://www.scala-lang.org/blog/2017/02/28/collections-rework.html) |
| 20 | +is closer to final form. |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +To depend on scala-parser-combinators in sbt, add this to your `build.sbt`: |
| 25 | + |
| 26 | +``` |
| 27 | +libraryDependencies += |
| 28 | + "org.scala-lang.modules" %% "scala-parser-combinators" % "0.1.2" |
| 29 | +``` |
| 30 | + |
| 31 | +In your code, adding this import: |
| 32 | + |
| 33 | +``` |
| 34 | +import scala.collection.parallel.CollectionConverters._ |
| 35 | +``` |
| 36 | + |
| 37 | +will enable use of the `.par` method as in earlier Scala versions. |
| 38 | + |
| 39 | +### Cross-building: dependency |
| 40 | + |
| 41 | +This module is published only for the Scala 2.13.x series, so in a |
| 42 | +cross-built project, the dependency should take this form: |
| 43 | + |
| 44 | +```scala |
| 45 | +libraryDependencies ++= |
| 46 | + CrossVersion.partialVersion(scalaVersion.value) match { |
| 47 | + case Some((2, minor)) if minor >= 13 => |
| 48 | + Seq("org.scala-lang.modules" %% "scala-parser-combinators" % "0.1.2") |
| 49 | + case _ => |
| 50 | + Seq() |
| 51 | + } |
| 52 | +``` |
| 53 | + |
| 54 | +This way of testing `scalaVersion` is robust across varying Scala |
| 55 | +version number formats (nightlies, milestones, release candidates, |
| 56 | +community build, etc). |
| 57 | + |
| 58 | +### Cross-building: source compatibility |
| 59 | + |
| 60 | +Using `.par` is problematic in a cross-built project, since in Scala |
| 61 | +2.13 the `CollectionConverters._` import shown above is necessary, but |
| 62 | +in earlier Scala versions, that import will not compile. |
| 63 | + |
| 64 | +You may able to avoid the problem by directly constructing your |
| 65 | +parallel collections rather than going through `.par`. For other |
| 66 | +possible workarounds, see |
| 67 | +https://github.com/scala/scala-parallel-collections/issues/22, |
| 68 | +which is still under discussion (as of April 2017). |
| 69 | + |
| 70 | +## Releasing |
| 71 | + |
| 72 | +As with other Scala standard modules, build and release infrastructure |
| 73 | +is provided by the |
| 74 | +[sbt-scala-modules](https://github.com/scala/sbt-scala-modules/) sbt |
| 75 | +plugin. |
0 commit comments