Android PipedOutputStream / PipedInputStream pass bytes byte seems wrong

Android implementation of PipedOutputStream

write(byte[] buffer, int offset, int count) 

implemented in terms of write (byte oneByte). More specifically, PipedOutputStream

write(byte[] buffer, int offset, int count)

implemented by looping bytes [] and calling write (byte oneByte) for each byte. See this .

Executing this method results in a received PipedInputStream call for each byte. This produces results in notifyAll, which wakes the reader and reads it. This way you get a lot of bytes.

I see that this is the correct implementation, but slow. Maybe there is some kind of Java convention that makes this wrong? Since array entry in PipedOutputStream now alternates with notification in PipedInputStream.

write [abc] causes the record (a) to notify the record (b) to notify the record (c) to notify.

+3
source share
1 answer

Yes, the code associated with it implies that it uses a standard implementation OutputStreamto send each single byteas it is. As far as I know, this actually correct, but probably quite inefficient.

0
source

Source: https://habr.com/ru/post/1795429/


All Articles