Merge pull request #17105 from akka/wip-async-stage-∂π

add async stage
This commit is contained in:
Roland Kuhn 2015-04-10 10:52:01 +02:00
commit 8f47b6dfcc
66 changed files with 981 additions and 787 deletions

View file

@ -8,7 +8,6 @@ import akka.stream.impl.Stages.{ MaterializingStageFactory, StageModule }
import akka.stream.{ SourceShape, Inlet, Outlet }
import akka.stream.impl.StreamLayout.{ EmptyModule, Module }
import akka.stream.stage.{ TerminationDirective, Directive, Context, PushPullStage }
import scala.annotation.unchecked.uncheckedVariance
import scala.language.higherKinds
import akka.actor.Props
@ -23,6 +22,7 @@ import akka.actor.Cancellable
import akka.actor.ActorRef
import scala.concurrent.Promise
import org.reactivestreams.Subscriber
import akka.stream.stage.SyncDirective
/**
* A `Source` is a set of stream processing steps that has one open output. It can comprise
@ -198,6 +198,7 @@ object Source extends SourceApply {
* A graph with the shape of a source logically is a source, this method makes
* it so also in type.
*/
// TODO optimize if no wrapping needed
def wrap[T, M](g: Graph[SourceShape[T], M]): Source[T, M] = new Source(g.module)
/**
@ -218,7 +219,7 @@ object Source extends SourceApply {
def initIterator(): Unit = if (iterator eq null) iterator = iterable.iterator
// Upstream is guaranteed to be empty
override def onPush(elem: Nothing, ctx: Context[T]): Directive =
override def onPush(elem: Nothing, ctx: Context[T]): SyncDirective =
throw new UnsupportedOperationException("The IterableSource stage cannot be pushed")
override def onUpstreamFinish(ctx: Context[T]): TerminationDirective = {
@ -227,7 +228,7 @@ object Source extends SourceApply {
else ctx.finish()
}
override def onPull(ctx: Context[T]): Directive = {
override def onPull(ctx: Context[T]): SyncDirective = {
if (!ctx.isFinishing) {
initIterator()
ctx.pull()