This is an automated email from the ASF dual-hosted git repository.

hepin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-grpc.git


The following commit(s) were added to refs/heads/main by this push:
     new 65d3683e chore: fuse handlers in CancellationBarrierGraphStage (#414)
65d3683e is described below

commit 65d3683e5ff2e9f166336d3ded35cb169870f0a8
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Fri Nov 29 00:33:42 2024 +0800

    chore: fuse handlers in CancellationBarrierGraphStage (#414)
---
 .../internal/CancellationBarrierGraphStage.scala   | 42 +++++++++-------------
 1 file changed, 17 insertions(+), 25 deletions(-)

diff --git 
a/runtime/src/main/scala/org/apache/pekko/grpc/internal/CancellationBarrierGraphStage.scala
 
b/runtime/src/main/scala/org/apache/pekko/grpc/internal/CancellationBarrierGraphStage.scala
index a6cc7282..d59a98b8 100644
--- 
a/runtime/src/main/scala/org/apache/pekko/grpc/internal/CancellationBarrierGraphStage.scala
+++ 
b/runtime/src/main/scala/org/apache/pekko/grpc/internal/CancellationBarrierGraphStage.scala
@@ -30,31 +30,23 @@ class CancellationBarrierGraphStage[T] extends 
GraphStage[FlowShape[T, T]] {
   override val shape: FlowShape[T, T] = FlowShape(in, out)
 
   override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
-    new GraphStageLogic(shape) {
-      setHandler(
-        in,
-        new InHandler {
-          override def onPush(): Unit = emit(out, grab(in))
-        })
-
-      setHandler(
-        out,
-        new OutHandler {
-          override def onPull(): Unit = pull(in)
-
-          override def onDownstreamFinish(cause: Throwable): Unit = {
-            if (!hasBeenPulled(in))
+    new GraphStageLogic(shape) with InHandler with OutHandler {
+      override def onPush(): Unit = emit(out, grab(in))
+      override def onPull(): Unit = pull(in)
+
+      override def onDownstreamFinish(cause: Throwable): Unit = {
+        if (!hasBeenPulled(in))
+          pull(in)
+
+        setHandler(
+          in,
+          new InHandler {
+            override def onPush(): Unit = {
+              grab(in)
               pull(in)
-
-            setHandler(
-              in,
-              new InHandler {
-                override def onPush(): Unit = {
-                  grab(in)
-                  pull(in)
-                }
-              })
-          }
-        })
+            }
+          })
+      }
+      setHandlers(in, out, this)
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to