Skip to content

Commit

Permalink
Merge pull request #40 from xuwei-k/procedure-syntax
Browse files Browse the repository at this point in the history
fix procedure syntax
  • Loading branch information
julienrf authored May 17, 2018
2 parents e5eb994 + 2851493 commit 03abdfb
Show file tree
Hide file tree
Showing 31 changed files with 118 additions and 118 deletions.
20 changes: 10 additions & 10 deletions core/src/main/scala/scala/collection/parallel/ParIterableLike.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
@volatile
private var _tasksupport = defaultTaskSupport

protected def initTaskSupport() {
protected def initTaskSupport(): Unit = {
_tasksupport = defaultTaskSupport
}

Expand Down Expand Up @@ -331,7 +331,7 @@ self: ParIterableLike[T, Repr, Sequential] =>

protected implicit def builder2ops[Elem, To](cb: Builder[Elem, To]) = new BuilderOps[Elem, To] {
def ifIs[Cmb](isbody: Cmb => Unit) = new Otherwise[Cmb] {
def otherwise(notbody: => Unit)(implicit t: ClassTag[Cmb]) {
def otherwise(notbody: => Unit)(implicit t: ClassTag[Cmb]): Unit = {
if (cb.getClass == t.runtimeClass) isbody(cb.asInstanceOf[Cmb]) else notbody
}
}
Expand Down Expand Up @@ -914,11 +914,11 @@ self: ParIterableLike[T, Repr, Sequential] =>
extends NonDivisibleTask[R, Composite[FR, SR, R, First, Second]] {
def combineResults(fr: FR, sr: SR): R
@volatile var result: R = null.asInstanceOf[R]
private[parallel] override def signalAbort() {
private[parallel] override def signalAbort(): Unit = {
ft.signalAbort()
st.signalAbort()
}
protected def mergeSubtasks() {
protected def mergeSubtasks(): Unit = {
ft mergeThrowables st
if (throwable eq null) result = combineResults(ft.result, st.result)
}
Expand Down Expand Up @@ -956,7 +956,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
val initialResult = tasksupport.executeAndWaitResult(inner)
result = map(initialResult)
}
private[parallel] override def signalAbort() {
private[parallel] override def signalAbort(): Unit = {
inner.signalAbort()
}
override def requiresStrictSplitters = inner.requiresStrictSplitters
Expand Down Expand Up @@ -1334,7 +1334,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
protected[this] class ToParCollection[U >: T, That](cbf: CombinerFactory[U, That], protected[this] val pit: IterableSplitter[T])
extends Transformer[Combiner[U, That], ToParCollection[U, That]] {
@volatile var result: Result = null
def leaf(prev: Option[Combiner[U, That]]) {
def leaf(prev: Option[Combiner[U, That]]): Unit = {
result = cbf()
while (pit.hasNext) result += pit.next
}
Expand All @@ -1345,7 +1345,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
protected[this] class ToParMap[K, V, That](cbf: CombinerFactory[(K, V), That], protected[this] val pit: IterableSplitter[T])(implicit ev: T <:< (K, V))
extends Transformer[Combiner[(K, V), That], ToParMap[K, V, That]] {
@volatile var result: Result = null
def leaf(prev: Option[Combiner[(K, V), That]]) {
def leaf(prev: Option[Combiner[(K, V), That]]): Unit = {
result = cbf()
while (pit.hasNext) result += pit.next
}
Expand Down Expand Up @@ -1394,7 +1394,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
(tree: ScanTree[U], z: U, op: (U, U) => U, cbf: CombinerFactory[U, That])
extends StrictSplitterCheckTask[Combiner[U, That], FromScanTree[U, That]] {
@volatile var result: Combiner[U, That] = null
def leaf(prev: Option[Combiner[U, That]]) {
def leaf(prev: Option[Combiner[U, That]]): Unit = {
val cb = reuse(prev, cbf())
iterate(tree, cb)
result = cb
Expand Down Expand Up @@ -1443,11 +1443,11 @@ self: ParIterableLike[T, Repr, Sequential] =>
val rightmost = right.rightmost

def beginsAt = left.beginsAt
def pushdown(v: U) {
def pushdown(v: U): Unit = {
left.pushdown(v)
right.pushdown(v)
}
def print(depth: Int) {
def print(depth: Int): Unit = {
println((" " * depth) + "ScanNode, begins at " + beginsAt)
left.print(depth + 1)
right.print(depth + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
r
}

override def copyToArray[U >: T](array: Array[U], from: Int, len: Int) {
override def copyToArray[U >: T](array: Array[U], from: Int, len: Int): Unit = {
var i = from
val until = from + len
while (i < until && hasNext) {
Expand Down Expand Up @@ -229,7 +229,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
(before, after)
}

def scanToArray[U >: T, A >: U](z: U, op: (U, U) => U, array: Array[A], from: Int) {
def scanToArray[U >: T, A >: U](z: U, op: (U, U) => U, array: Array[A], from: Int): Unit = {
var last = z
var i = from
while (hasNext) {
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/scala/scala/collection/parallel/Tasks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ trait Task[R, +Tp] {
private[parallel] def split: Seq[Task[R, Tp]]

/** Read of results of `that` task and merge them into results of this one. */
private[parallel] def merge(that: Tp @uncheckedVariance) {}
private[parallel] def merge(that: Tp @uncheckedVariance): Unit = {}

// exception handling mechanism
@volatile var throwable: Throwable = null
def forwardThrowable() = if (throwable != null) throw throwable

// tries to do the leaf computation, storing the possible exception
private[parallel] def tryLeaf(lastres: Option[R]) {
private[parallel] def tryLeaf(lastres: Option[R]): Unit = {
try {
tryBreakable {
leaf(lastres)
Expand All @@ -58,21 +58,21 @@ trait Task[R, +Tp] {
}
}

private[parallel] def tryMerge(t: Tp @uncheckedVariance) {
private[parallel] def tryMerge(t: Tp @uncheckedVariance): Unit = {
val that = t.asInstanceOf[Task[R, Tp]]
if (this.throwable == null && that.throwable == null) merge(t)
mergeThrowables(that)
}

private[parallel] def mergeThrowables(that: Task[_, _]) {
private[parallel] def mergeThrowables(that: Task[_, _]): Unit = {
if (this.throwable != null && that.throwable != null)
this.throwable.addSuppressed(that.throwable)
else if (this.throwable == null && that.throwable != null)
this.throwable = that.throwable
}

// override in concrete task implementations to signal abort to other tasks
private[parallel] def signalAbort() {}
private[parallel] def signalAbort(): Unit = {}
}


Expand Down Expand Up @@ -109,7 +109,7 @@ trait Tasks {
*
* This method may be overridden.
*/
def release() {}
def release(): Unit = {}
}

/* task control */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ self =>

/* debug */

private[parallel] def printDebugInfo() {
private[parallel] def printDebugInfo(): Unit = {
println("Parallel hash trie")
println("Top level inner trie type: " + trie.getClass)
trie match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ self =>
this
}

override def copyToArray[U >: T](array: Array[U], from: Int, len: Int) {
override def copyToArray[U >: T](array: Array[U], from: Int, len: Int): Unit = {
val totallen = (self.length - i) min len min (array.length - from)
Array.copy(arr, i, array, from, totallen)
i += totallen
Expand Down Expand Up @@ -384,7 +384,7 @@ self =>
cb
}

private def map2combiner_quick[S, That](f: T => S, a: Array[Any], cb: Builder[S, That], ntil: Int, from: Int) {
private def map2combiner_quick[S, That](f: T => S, a: Array[Any], cb: Builder[S, That], ntil: Int, from: Int): Unit = {
var j = from
while (j < ntil) {
cb += f(a(j).asInstanceOf[T])
Expand All @@ -399,7 +399,7 @@ self =>
cb
}

private def collect2combiner_quick[S, That](pf: PartialFunction[T, S], a: Array[Any], cb: Builder[S, That], ntil: Int, from: Int) {
private def collect2combiner_quick[S, That](pf: PartialFunction[T, S], a: Array[Any], cb: Builder[S, That], ntil: Int, from: Int): Unit = {
var j = from
val runWith = pf.runWith(b => cb += b)
while (j < ntil) {
Expand All @@ -426,7 +426,7 @@ self =>
cb
}

private def filter2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int) {
private def filter2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int): Unit = {
var j = i
while(j < ntil) {
val curr = a(j).asInstanceOf[T]
Expand All @@ -441,7 +441,7 @@ self =>
cb
}

private def filterNot2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int) {
private def filterNot2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int): Unit = {
var j = i
while(j < ntil) {
val curr = a(j).asInstanceOf[T]
Expand Down Expand Up @@ -474,7 +474,7 @@ self =>
cb
}

private def copy2builder_quick[U >: T, Coll](b: Builder[U, Coll], a: Array[Any], ntil: Int, from: Int) {
private def copy2builder_quick[U >: T, Coll](b: Builder[U, Coll], a: Array[Any], ntil: Int, from: Int): Unit = {
var j = from
while (j < ntil) {
b += a(j).asInstanceOf[T]
Expand All @@ -488,7 +488,7 @@ self =>
(btrue, bfalse)
}

private def partition2combiners_quick[U >: T, This](p: T => Boolean, btrue: Builder[U, This], bfalse: Builder[U, This], a: Array[Any], ntil: Int, from: Int) {
private def partition2combiners_quick[U >: T, This](p: T => Boolean, btrue: Builder[U, This], bfalse: Builder[U, This], a: Array[Any], ntil: Int, from: Int): Unit = {
var j = from
while (j < ntil) {
val curr = a(j).asInstanceOf[T]
Expand Down Expand Up @@ -542,7 +542,7 @@ self =>
cb
}

private def reverse2combiner_quick(targ: Array[Any], a: Array[Any], targfrom: Int, srcfrom: Int, srcuntil: Int) {
private def reverse2combiner_quick(targ: Array[Any], a: Array[Any], targfrom: Int, srcfrom: Int, srcuntil: Int): Unit = {
var j = srcfrom
var k = targfrom + srcuntil - srcfrom - 1
while (j < srcuntil) {
Expand All @@ -552,12 +552,12 @@ self =>
}
}

override def scanToArray[U >: T, A >: U](z: U, op: (U, U) => U, destarr: Array[A], from: Int) {
override def scanToArray[U >: T, A >: U](z: U, op: (U, U) => U, destarr: Array[A], from: Int): Unit = {
scanToArray_quick[U](array, destarr.asInstanceOf[Array[Any]], op, z, i, until, from)
i = until
}

protected def scanToArray_quick[U](srcarr: Array[Any], destarr: Array[Any], op: (U, U) => U, z: U, srcfrom: Int, srcntil: Int, destfrom: Int) {
protected def scanToArray_quick[U](srcarr: Array[Any], destarr: Array[Any], op: (U, U) => U, z: U, srcfrom: Int, srcntil: Int, destfrom: Int): Unit = {
var last = z
var j = srcfrom
var k = destfrom
Expand Down Expand Up @@ -619,7 +619,7 @@ self =>
case ScanLeaf(_, _, from, len, None, _) =>
scanLeaf(array, targetarr, from, len, z)
}
private def scanLeaf(srcarr: Array[Any], targetarr: Array[Any], from: Int, len: Int, startval: U) {
private def scanLeaf(srcarr: Array[Any], targetarr: Array[Any], from: Int, len: Int, startval: U): Unit = {
var i = from
val until = from + len
var curr = startval
Expand Down Expand Up @@ -665,11 +665,11 @@ self =>

/* serialization */

private def writeObject(out: java.io.ObjectOutputStream) {
private def writeObject(out: java.io.ObjectOutputStream): Unit = {
out.defaultWriteObject
}

private def readObject(in: java.io.ObjectInputStream) {
private def readObject(in: java.io.ObjectInputStream): Unit = {
in.defaultReadObject

// get raw array from arrayseq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait ParFlatHashTable[T] extends scala.collection.mutable.FlatHashTable[T] {

if (hasNext) scan()

private[this] def scan() {
private[this] def scan(): Unit = {
while (itertable(idx) eq null) {
idx += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ self =>
new Entry(key, value.asInstanceOf[V])
}

private def writeObject(out: java.io.ObjectOutputStream) {
private def writeObject(out: java.io.ObjectOutputStream): Unit = {
serializeTo(out, { entry =>
out.writeObject(entry.key)
out.writeObject(entry.value)
})
}

private def readObject(in: java.io.ObjectInputStream) {
private def readObject(in: java.io.ObjectInputStream): Unit = {
init(in, createNewEntry(in.readObject().asInstanceOf[K], in.readObject()))
}

Expand Down Expand Up @@ -190,7 +190,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
// TODO parallelize by keeping separate sizemaps and merging them
object table extends HashTable[K, DefaultEntry[K, V]] {
type Entry = DefaultEntry[K, V]
def insertEntry(e: Entry) { super.findOrAddEntry(e.key, e) }
def insertEntry(e: Entry): Unit = { super.findOrAddEntry(e.key, e) }
def createNewEntry[E](key: K, entry: E): Entry = entry.asInstanceOf[Entry]
sizeMapInit(table.length)
}
Expand Down Expand Up @@ -285,7 +285,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
val fp = howmany / 2
List(new FillBlocks(buckets, table, offset, fp), new FillBlocks(buckets, table, offset + fp, howmany - fp))
}
override def merge(that: FillBlocks) {
override def merge(that: FillBlocks): Unit = {
this.result += that.result
}
def shouldSplitFurther = howmany > scala.collection.parallel.thresholdFromSize(ParHashMapCombiner.numblocks, combinerTaskSupport.parallelismLevel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ extends ParSet[T]
def newIterator(start: Int, until: Int, total: Int) = new ParHashSetIterator(start, until, total)
}

private def writeObject(s: java.io.ObjectOutputStream) {
private def writeObject(s: java.io.ObjectOutputStream): Unit = {
serializeTo(s)
}

private def readObject(in: java.io.ObjectInputStream) {
private def readObject(in: java.io.ObjectInputStream): Unit = {
init(in, x => ())
}

Expand Down Expand Up @@ -238,7 +238,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
extends Task[(Int, UnrolledBuffer[AnyRef]), FillBlocks] {
var result = (Int.MinValue, new UnrolledBuffer[AnyRef])

def leaf(prev: Option[(Int, UnrolledBuffer[AnyRef])]) {
def leaf(prev: Option[(Int, UnrolledBuffer[AnyRef])]): Unit = {
var i = offset
var totalinserts = 0
var leftover = new UnrolledBuffer[AnyRef]()
Expand Down Expand Up @@ -301,7 +301,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
val fp = howmany / 2
List(new FillBlocks(buckets, table, offset, fp), new FillBlocks(buckets, table, offset + fp, howmany - fp))
}
override def merge(that: FillBlocks) {
override def merge(that: FillBlocks): Unit = {
// take the leftovers from the left task, store them into the block of the right task
val atPos = blockStart(that.offset)
val beforePos = blockStart(that.offset + that.howmany)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ trait ParHashTable[K, Entry >: Null <: HashEntry[K, Entry]] extends scala.collec
entry2item(res)
}

def scan() {
def scan(): Unit = {
while (es == null && idx < until) {
es = itertable(idx).asInstanceOf[Entry]
idx = idx + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ trait ResizableParArrayCombiner[T] extends LazyCombiner[T, ParArray[T], ExposedA
ind = 0
}
}
private def copyChunk(buffarr: Array[AnyRef], buffStart: Int, ra: Array[Any], arrayStart: Int, until: Int) {
private def copyChunk(buffarr: Array[AnyRef], buffStart: Int, ra: Array[Any], arrayStart: Int, until: Int): Unit = {
Array.copy(buffarr, buffStart, ra, arrayStart, until - buffStart)
}
private def findStart(pos: Int) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extends Combiner[T, ParArray[T]] {
new ParArray(arrayseq)
}

def clear() {
def clear(): Unit = {
buff.clear()
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/scala/collection/parallel/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ package parallel {
sz = 0
}

def beforeCombine[N <: Elem, NewTo >: To](other: Combiner[N, NewTo]) {}
def beforeCombine[N <: Elem, NewTo >: To](other: Combiner[N, NewTo]): Unit = {}

def afterCombine[N <: Elem, NewTo >: To](other: Combiner[N, NewTo]) {}
def afterCombine[N <: Elem, NewTo >: To](other: Combiner[N, NewTo]): Unit = {}

def combine[N <: Elem, NewTo >: To](other: Combiner[N, NewTo]): Combiner[N, NewTo] = {
if (this eq other) this
Expand Down
Loading

0 comments on commit 03abdfb

Please sign in to comment.