scala - Splitter.isParallel returns false? (Version 2.10.2) -


i have code monitors progress of foreach method needs able detect whether foreach loop happen in parallel choose appropriate progress tracking algorithm. spent time tracking down bug , isolated this:

scala> vector(1,2,3).iterator.isparallel res11: boolean = false scala> vector(1,2,3).isparallel res12: boolean = false scala> vector(1,2,3).par.isparallel res13: boolean = true ...  scala> vector(1,2,3).par.splitter.isparallel res13: boolean = false scala> vector(1,2,3).par.iterator.isparallel res14: boolean = false 

is bug or misunderstand function?

the isparallel method defined in traversableops class, various of collection classes via implicit conversion. relevant source snippet (from scala/collection/parallel/package.scala) is:

implicit def traversable2ops[t](t: scala.collection.gentraversableonce[t]) = new traversableops[t] {   def isparallel = t.isinstanceof[parallel]   ... } 

as can seen this, class needs extend parallel marker trait return true method. turns out, various parallelised collections this, iterators don't. is, appears parallel has been used mark actual collections, not helpers. don't know whether intended or if argued oversight.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -