make fused graphs fusable

This commit is contained in:
Roland Kuhn 2015-12-15 16:44:48 +01:00
parent 3d20915cf4
commit e4f31b66c3
7 changed files with 308 additions and 95 deletions

View file

@ -7,6 +7,8 @@ import java.{ util ⇒ ju }
import scala.collection.immutable
import scala.collection.JavaConverters._
import akka.stream.impl.StreamLayout._
import akka.stream.impl.fusing.{ Fusing Impl }
import scala.annotation.unchecked.uncheckedVariance
/**
* This class holds some graph transformation functions that can fuse together
@ -32,15 +34,19 @@ object Fusing {
* via [[akka.stream.Attributes#AsyncBoundary]].
*/
def aggressive[S <: Shape, M](g: Graph[S, M]): FusedGraph[S, M] =
akka.stream.impl.fusing.Fusing.aggressive(g)
g match {
case fg: FusedGraph[_, _] fg
case _ Impl.aggressive(g)
}
/**
* A fused graph of the right shape, containing a [[FusedModule]] which
* holds more information on the operation structure of the contained stream
* topology for convenient graph traversal.
*/
case class FusedGraph[S <: Shape, M](override val module: FusedModule,
override val shape: S) extends Graph[S, M] {
case class FusedGraph[+S <: Shape @uncheckedVariance, +M](override val module: FusedModule,
override val shape: S) extends Graph[S, M] {
// the @uncheckedVariance look like a compiler bug ... why does it work in Graph but not here?
override def withAttributes(attr: Attributes) = copy(module = module.withAttributes(attr))
}
@ -54,6 +60,7 @@ object Fusing {
final case class StructuralInfo(upstreams: immutable.Map[InPort, OutPort],
downstreams: immutable.Map[OutPort, InPort],
inOwners: immutable.Map[InPort, Module],
outOwners: immutable.Map[OutPort, Module])
outOwners: immutable.Map[OutPort, Module],
allModules: Set[Module])
}