Merge pull request #17675 from akka/wip-remove-synchronousiterablepublisher-√
=str - Wip remove synchronousiterablepublisher √
This commit is contained in:
commit
ca5d27abbd
10 changed files with 69 additions and 418 deletions
|
|
@ -7,7 +7,7 @@ import akka.actor.{ ActorRef, Cancellable, Props }
|
|||
import akka.stream._
|
||||
import akka.stream.impl.Stages.{ MaterializingStageFactory, StageModule }
|
||||
import akka.stream.impl.Stages.DefaultAttributes
|
||||
import akka.stream.impl.{ EmptyPublisher, ErrorPublisher, SynchronousIterablePublisher, _ }
|
||||
import akka.stream.impl.{ EmptyPublisher, ErrorPublisher, _ }
|
||||
import akka.stream.stage.{ Context, PushPullStage, SyncDirective, TerminationDirective }
|
||||
import org.reactivestreams.{ Publisher, Subscriber }
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ import akka.stream.stage.{ TerminationDirective, Directive, Context, PushPullSta
|
|||
import scala.annotation.unchecked.uncheckedVariance
|
||||
import scala.language.higherKinds
|
||||
import akka.actor.Props
|
||||
import akka.stream.impl.{ EmptyPublisher, ErrorPublisher, SynchronousIterablePublisher }
|
||||
import akka.stream.impl.{ EmptyPublisher, ErrorPublisher }
|
||||
import org.reactivestreams.Publisher
|
||||
import scala.collection.immutable
|
||||
import scala.concurrent.duration.FiniteDuration
|
||||
|
|
@ -165,6 +165,9 @@ final class Source[+Out, +Mat](private[stream] override val module: Module)
|
|||
|
||||
object Source extends SourceApply {
|
||||
|
||||
private[this] final val _id: Any ⇒ Any = x ⇒ x
|
||||
private[this] final def id[A]: A ⇒ A = _id.asInstanceOf[A ⇒ A]
|
||||
|
||||
private[stream] def apply[Out, Mat](module: SourceModule[Out, Mat]): Source[Out, Mat] =
|
||||
new Source(module)
|
||||
|
||||
|
|
@ -192,11 +195,8 @@ object Source extends SourceApply {
|
|||
* Elements are pulled out of the iterator in accordance with the demand coming
|
||||
* from the downstream transformation steps.
|
||||
*/
|
||||
def apply[T](f: () ⇒ Iterator[T]): Source[T, Unit] = {
|
||||
apply(new immutable.Iterable[T] {
|
||||
override def iterator: Iterator[T] = f()
|
||||
})
|
||||
}
|
||||
def apply[T](f: () ⇒ Iterator[T]): Source[T, Unit] =
|
||||
apply(new immutable.Iterable[T] { override def iterator: Iterator[T] = f() })
|
||||
|
||||
/**
|
||||
* A graph with the shape of a source logically is a source, this method makes
|
||||
|
|
@ -216,9 +216,8 @@ object Source extends SourceApply {
|
|||
* stream will see an individual flow of elements (always starting from the
|
||||
* beginning) regardless of when they subscribed.
|
||||
*/
|
||||
def apply[T](iterable: immutable.Iterable[T]): Source[T, Unit] = {
|
||||
Source.single(()).mapConcat((_: Unit) ⇒ iterable).withAttributes(DefaultAttributes.iterableSource)
|
||||
}
|
||||
def apply[T](iterable: immutable.Iterable[T]): Source[T, Unit] =
|
||||
Source.single(iterable).mapConcat(id).withAttributes(DefaultAttributes.iterableSource)
|
||||
|
||||
/**
|
||||
* Start a new `Source` from the given `Future`. The stream will consist of
|
||||
|
|
@ -227,7 +226,7 @@ object Source extends SourceApply {
|
|||
* The stream terminates with a failure if the `Future` is completed with a failure.
|
||||
*/
|
||||
def apply[T](future: Future[T]): Source[T, Unit] =
|
||||
new Source(new FutureSource(future, DefaultAttributes.futureSource, shape("FutureSource")))
|
||||
Source.single(future).mapAsyncUnordered(1)(id).withAttributes(DefaultAttributes.futureSource)
|
||||
|
||||
/**
|
||||
* Elements are emitted periodically with the specified interval.
|
||||
|
|
@ -244,7 +243,7 @@ object Source extends SourceApply {
|
|||
* Every connected `Sink` of this stream will see an individual stream consisting of one element.
|
||||
*/
|
||||
def single[T](element: T): Source[T, Unit] =
|
||||
apply(SynchronousIterablePublisher(List(element), "SingleSource")).withAttributes(DefaultAttributes.singleSource) // FIXME optimize
|
||||
apply(SingleElementPublisher(element, "SingleSource")).withAttributes(DefaultAttributes.singleSource) // FIXME optimize
|
||||
|
||||
/**
|
||||
* Create a `Source` that will continually emit the given element.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue