jfriesne/muscle — pull request #4 by bvarner (2014-09-03 14:04:26+00:00)
Title: NIO Stability & Performance changes

* Fixed a bug causing communication failures in the NIO message unflattening.
* Prior to throwing a NotEnoughDataException the position of the buffer wasn't being updated in MessageIOGateway and JZLibMessageIOGateway.
* Updated the handling code for NotEnoughDataExceptions to no longer rely on the position of the buffer (but rather look at the buffer limit, or the amount previously read into the buffer) -- which basically makes the above change unnecessary, but I'm paranoid.
* Performance Related
* Switched to a direct byte buffer, which is allocated by the OS outside of the GC's managed space.
* Scoped the receiving byte buffer to the receiver, which cut down on a lot of time spent allocating short-lived buffers.
* Added a constructor for the MessageReceiver to allocate it's buffer to the same size as the sockets underlying buffer and made use of the call where possible.