Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Commit

Permalink
Performance improvement, moving write and flush out of enframed and i…
Browse files Browse the repository at this point in the history
…nto framed write itself
  • Loading branch information
sbuzzard committed Apr 5, 2016
1 parent d9eb5c9 commit cfd262b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/transport/netty/Client.scala
Expand Up @@ -70,7 +70,7 @@ object NettyTransport {
})
}

def write(c: Channel)(frame: Framed): Task[Unit] = evalCF(c.write(frame))
def write(c: Channel)(frame: Framed): Task[Unit] = evalCF(c.writeAndFlush(frame))

def single(host: InetSocketAddress,
expectedSigs: Set[Signature] = Set.empty,
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/transport/netty/Transport.scala
Expand Up @@ -126,7 +126,7 @@ class Deframe extends ByteToMessageDecoder {
} else {
remaining = Some(rem)
}
}
}
case Some(rem) =>
// we are waiting for at least rem more bytes, as that is what
// is outstanding in the current frame
Expand Down Expand Up @@ -177,9 +177,9 @@ object Enframe extends ChannelOutboundHandlerAdapter {
obj match {
case Bits(bv) =>
val byv = bv.toByteVector
val _ = ctx.writeAndFlush(Unpooled.wrappedBuffer((codecs.int32.encode(byv.size).require ++ bv).toByteBuffer), cp)
val _ = ctx.write(Unpooled.wrappedBuffer((codecs.int32.encode(byv.size).require ++ bv).toByteBuffer), cp)
case EOS =>
val _ = ctx.writeAndFlush(Unpooled.wrappedBuffer(codecs.int32.encode(0).require.toByteBuffer), cp)
val _ = ctx.write(Unpooled.wrappedBuffer(codecs.int32.encode(0).require.toByteBuffer), cp)
case x => throw new IllegalArgumentException("was expecting Framed, got: " + x)
}
}
Expand Down

0 comments on commit cfd262b

Please sign in to comment.