On Thu, Feb 7, 2013 at 8:20 AM, Phil Harvey <[email protected]>wrote:
> Thanks for the clear description Rafi. The modified interface sounds
> reasonable, notwithstanding the resolution of the questions about naming,
> and of the valid lifespan of the input/output pointers.
>
> We're currently looking at the impact on proton-j and will respond more
> fully once we've got a better understanding of it.
>
> I believe there has been some brief discussion off-list of how the
> corresponding Java Transport API would look. This will be implemented both
> in pure Java and via JNI calls to proton-c. I've summarised my second-hand
> understanding of the proposed Java API below.
>
> interface Transport
> {
> /**
> * Like pn_transport_buffer.
> * The ByteBuffer.remaining() method obviates the need for a
> pn_transport_capacity equivalent
> */
> ByteBuffer getInputBuffer();
>
> /** like push. No need for corresponding size parameter because the
> input buffer's position() implies it */
> int processInput();
>
> /** like pn_transport_peek */
> ByteBuffer getOutputBuffer();
>
> /** like pop */
> int outputWritten();
>
> /** ... deprecated existing input/output methods */
> }
>
Seems reasonable. Given my rusty recollection of ByteBuffer semantics,
would you mind spelling out what maps to pending and the size parameter to
pop? Also, what are the constraints in usage of the buffers? I understand
the use of ByteBuffer is needed in order to directly address C memory
without a copy, but am I right in thinking that not all usage of the
exposed ByteBuffer's would be safe, e.g. it would probably mess with the
transport to call flip or compact the byte array or something like that. Is
there an easy way to describe what is/isn't allowed?
--Rafael