=str Remove outHandler of FlattenMerge (#29890)
This commit is contained in:
parent
8bb74b592d
commit
8c0ffe3b2a
1 changed files with 70 additions and 71 deletions
|
|
@ -39,7 +39,8 @@ import akka.util.ccompat.JavaConverters._
|
||||||
override def initialAttributes = DefaultAttributes.flattenMerge
|
override def initialAttributes = DefaultAttributes.flattenMerge
|
||||||
override val shape = FlowShape(in, out)
|
override val shape = FlowShape(in, out)
|
||||||
|
|
||||||
override def createLogic(enclosingAttributes: Attributes) = new GraphStageLogic(shape) {
|
override def createLogic(enclosingAttributes: Attributes) =
|
||||||
|
new GraphStageLogic(shape) with OutHandler with InHandler {
|
||||||
var sources = Set.empty[SubSinkInlet[T]]
|
var sources = Set.empty[SubSinkInlet[T]]
|
||||||
var pendingSingleSources = 0
|
var pendingSingleSources = 0
|
||||||
def activeSources = sources.size + pendingSingleSources
|
def activeSources = sources.size + pendingSingleSources
|
||||||
|
|
@ -62,27 +63,25 @@ import akka.util.ccompat.JavaConverters._
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setHandler(in, new InHandler {
|
|
||||||
override def onPush(): Unit = {
|
override def onPush(): Unit = {
|
||||||
val source = grab(in)
|
val source = grab(in)
|
||||||
addSource(source)
|
addSource(source)
|
||||||
if (activeSources < breadth) tryPull(in)
|
if (activeSources < breadth) tryPull(in)
|
||||||
}
|
}
|
||||||
override def onUpstreamFinish(): Unit = if (activeSources == 0) completeStage()
|
|
||||||
})
|
|
||||||
|
|
||||||
setHandler(out, new OutHandler {
|
override def onUpstreamFinish(): Unit = if (activeSources == 0) completeStage()
|
||||||
override def onPull(): Unit = {
|
override def onPull(): Unit = {
|
||||||
pull(in)
|
pull(in)
|
||||||
setHandler(out, outHandler)
|
setHandler(out, new OutHandler {
|
||||||
|
override def onPull(): Unit = {
|
||||||
|
// could be unavailable due to async input having been executed before this notification
|
||||||
|
if (queue.nonEmpty && isAvailable(out)) pushOut()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
val outHandler = new OutHandler {
|
|
||||||
// could be unavailable due to async input having been executed before this notification
|
|
||||||
override def onPull(): Unit = if (queue.nonEmpty && isAvailable(out)) pushOut()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setHandlers(in, out, this)
|
||||||
|
|
||||||
def addSource(source: Graph[SourceShape[T], M]): Unit = {
|
def addSource(source: Graph[SourceShape[T], M]): Unit = {
|
||||||
// If it's a SingleSource or wrapped such we can push the element directly instead of materializing it.
|
// If it's a SingleSource or wrapped such we can push the element directly instead of materializing it.
|
||||||
// Have to use AnyRef because of OptionVal null value.
|
// Have to use AnyRef because of OptionVal null value.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue