Hi,

as I was looking at the NioSelectorProcessor, and more specifically the part which reads data from the channel, I found that we are using a global buffer (readBuffer). I have two concerns in this area :

- first, we may need to copy the buffer if we need to add an executor in the chain. We may *not* have to do that, fait enough, but I'm quite sure that we may encounter issue later if we don't. At least, I would make it optionnal to protect us from such a potential issue. Am I alone having this feeling ? - second, I'm wondering if it would not be a better idea to either use a wider buffer - say 64k -, or to iterate on the read until we have sucked every bytes, storing them in as many buffers as needed, to avoid a costly round trip through the chain for each 1024 bytes we will have in the channel. Something like :

do {
  int readCount = channel.read(readBuffer[bufNumber++]);
} while ( readCount >= 0);

There is some suggestion to make the allocated buffer configurable, and I'm totally +1 for such an approach, but maybe starting with bigger buffers, and eventually create other buffers to store the data, before sending them into the chain, is also a good thing.

wdyt ?

--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Reply via email to