[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Re: [RFA/JDWP] Event basics

From: Cedric Berger
Subject: [cp-patches] Re: [RFA/JDWP] Event basics
Date: Thu, 23 Jun 2005 20:33:32 +0200
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Keith Seitz wrote:

On Wed, 2005-06-22 at 23:45 +0200, Cedric Berger wrote:

 public void toPacket(ByteBuffer bb, int requestId, byte suspendPolicy)

That looks simple enough except for one problem: ByteBuffers are fixed-
size quantities, aren't they?
Yeah, if you have many unbounded variable-length packet,
then using ByteBuffer is probably not the best idea.

_writeData can put an arbitrarily large amount of data into the buffer.
For simply event notifications like a ThreadStart, the only data is the
eight-byte thread ID. For some events like ClassPrepare, we have random
strings that are going to be inserted into the buffer.

In order to accomplish allocating the properly sized buffer ahead of
time, I'd need to add methods to all these things to compute the size of
the data.

Would this be worth the added complexity and computation? I dunno. What
do you think?
I don't think you should allocate ByteBuffer for each event.
There should be one big native ByteBuffer for each socket,
and you should reuse it for sending all messages.

So you could for example allocate one big 64k buffer and
do everything with it. Now if you cannot find a reasonable
upper limits for these packets, then it is probably easier
not to use nio and work with a DataOutputStream.

If you use DataOutputStream, then I think you should just
pass your global DataOutputStream to the toPacket() method,
instead of allocating temporary packet data.

Does that makes sense?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]