-
Added method
andThen
to allow chaining a side-effect, to be executed when theSkiis
has been completely consumed. The execution is guaranteed to happen at most once. (There is no guarantee the side-effect will be evaluated at all, since the Skiis may not ever be fully consumed.)This method is intended to support use-cases where a
Skiis
(or a derivedIterator
) is passed to some other code and cleanup/completion is needed afterwards. An example might be shutting down theSkiis.Context
executor.Of course, this isn't the best of designs but it may be the best available option in contexts where, e.g., there is no better available scoping/lifecycle structure around the production/consumption of Skiis/Iterators. Caveat emptor.
-
Optimization: removed an unnecessary synchronization in
Skiis.++
, the Skiis concatenation operator.
Version 2 introduces several backward-incompatible changes and as a result
the package name was changed from skiis
to skiis2
to allow both v1/v2 to
coexist in applications.
-
The
Skiis.Context
is now explicit to all parallel operations.This is to avoid a common pitfall where the same context is used in several parallel operations without realizing it, which can lead to issues of starvation and deadlock.
The recommended practice is to use different
Skiis.Context
for all parallel operations that are combined together, and of course tailoring queuing, batch and parallelism parameters to each stage. -
The existing
pull()
method was renamed todiscardAll()
to better reflect its semantic, which is to force evaluation of previous lazy computations and discard all resulting values. -
The
pull()
andparPull()
methods were repurposed to return aSkiis[T]
collection instead of returningUnit
. Both force the evaluation of previous lazy computation and place resulting values in a queue (of explicitly specified size) for consumption by the next stage. -
A new method
to[Collection]
was added which behaves the same as standard Scala collections. It is used to convert aSkiis[T]
to an arbitraryCollection[T]
, e.g.,skiis.to[IndexedSeq] => IndexedSeq[T] skiis.to(Set) => Set[T]
-
A new method
serialize()
can be used to force serialized (no parallelism, no concurrency) execution of any preceeding computation up to the preceeding stage. -
The
parForeachAsync()
method andControl
trait have been marked as@Experimental
to set expectations and prevent premature production use. -
A new method
Skiis.newCachedThreadPool(name)
was introduced for convenience, which, similarly tonewFixedThreadPool
, creates named daemond threads. -
Skiis.Context
has a new methodshutdown(now: Boolean)
to conditionally shutdown its executor, and a corresponding abstract fieldshutdownExecutor
was added. -
A new convenience method
Context.submit(f: => T)
was added to easily submit asynchronous jobs into a Context's thread pool. -
A new convenience method
Skiis.submit(f: => T)
was added to easily submit asynchronous jobs into Skiis' internal cached thread pool and returns a ScalaFuture[T]
. -
A new
copy()
method was added toSkiis.Context
and behaves as a case-class copy constructor. -
The
DefaultContext
now uses aCachedThreadPool
executor (to prevent accidental starvation/deadlocks if reused across multiple stages) and defaults to the following values:val parallelism = (Runtime.getRuntime.availableProcessors + 1) * 10 val queue = parallelism val batch = 1 val shutdownExecutor = true
As the updated Scaladoc says, this context is not meant to be used in production applications. It should only be useful to lazy programmers who want to conveniently ignore best practices until their day of reckoning or when Murphy's law kicks in, whichever comes first.
-
The
DeterministicContext
object was converted into aclass
to help prevent reuse in multiple stages of a Skiis pipeline. Its scaladoc was updated with warnings and disclaimers for the unsuspecting programmer. -
A new method
parFold()
provides the ability to fold aSkiis[T]
in parallel by using as many folding values ascontext.parallelism
indicates. -
A new method
parFoldMap()
provides a combination of parallel fold and flatMap. It encodes a common pattern where aSkiis[T]
is processed concurrently in a stateful manner and yields anotherSkiis[U]
. Since the states may reference or carry resources,parFoldMap(()
supports init/dispose blocks. -
New methods
parMapWithQueue()
andparFoldWithQueue()
are optimized versions ofparFlatMap()
andparFoldMap()
where the supplied functions (procedures) must directly produce to the result queue instead of yielding values. -
A new method
fanout(queues: Int, queueSize: Int): IndexedSeq[Queue[T]]
can be used to replicate aSkiis[T]
and create a fan-out pattern by replicating each element in multiple fan-out queues. -
Skiis.Queue[T]
now providescancel()
andreportException()
methods to cancel or fail dependent computations.
For changes prior to V2, please see CHANGELOG-v1.md
.