=str - Various internal Akka Stream improvements

* Gives Inlets and Outlets a `carbonCopy` method and switches to allocate them via `apply`
* Removes 4 Array allocations per FanIn and uses a bitmasked array instead
* Makes the FlattenStrategy.concat instance a singleton
This commit is contained in:
Viktor Klang 2015-06-13 16:28:38 -04:00
parent 65a425fe0b
commit 2725bfc044
30 changed files with 159 additions and 134 deletions

View file

@ -300,12 +300,7 @@ private[stream] object VirtualProcessor {
case object Completed extends Termination
case class Failed(ex: Throwable) extends Termination
private object InertSubscriber extends Subscriber[Any] {
override def onSubscribe(s: Subscription): Unit = s.cancel()
override def onNext(elem: Any): Unit = ()
override def onError(thr: Throwable): Unit = ()
override def onComplete(): Unit = ()
}
private val InertSubscriber = new CancellingSubscriber[Any]
}
private[stream] final class VirtualProcessor[T] extends Processor[T, T] {
@ -403,12 +398,12 @@ private[stream] final class VirtualProcessor[T] extends Processor[T, T] {
* INTERNAL API
*/
private[stream] final case class MaterializedValueSource[M](
shape: SourceShape[M] = SourceShape[M](new Outlet[M]("Materialized.out")),
shape: SourceShape[M] = SourceShape[M](Outlet[M]("Materialized.out")),
attributes: Attributes = Attributes.name("Materialized")) extends StreamLayout.Module {
override def subModules: Set[Module] = Set.empty
override def withAttributes(attr: Attributes): Module = this.copy(shape = amendShape(attr), attributes = attr)
override def carbonCopy: Module = this.copy(shape = SourceShape(new Outlet[M]("Materialized.out")))
override def carbonCopy: Module = this.copy(shape = SourceShape(Outlet[M]("Materialized.out")))
override def replaceShape(s: Shape): Module =
if (s == shape) this
@ -418,7 +413,7 @@ private[stream] final case class MaterializedValueSource[M](
attr.nameOption match {
case None shape
case s: Some[String] if s == attributes.nameOption shape
case Some(name) shape.copy(outlet = new Outlet(name + ".out"))
case Some(name) shape.copy(outlet = Outlet(name + ".out"))
}
}