Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: A stream/pipe that fills only on demand... Date: Sat, 08 Nov 2014 11:20:02 +0100 Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net pDaRe/LtCZhPlVzEZNpNawQuWwJi4uc2wFMvJBrNc7BKjOwiU= Cancel-Lock: sha1:cLNlB+dEKVv/gKzu7p27Trzvx6Q= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:30311 On 07.11.2014 10:34, Andreas Leitgeb wrote: > Normally, when one has a pipe-stream, the pipe gets filled on > one side, till its full, and drained on the other side while > data is needed. If less data is needed, then the remaining data > in the pipe is discarded. (simplified; no nitpicking, please) That is not an accurate description of how this "normally" works. If more data is in the pipe (which is just a queue) than is read it just sits there and will be retrieved later. Nothing is discarded. Also, whether a pipe is filled until it is full depends on the ratio between reading and writing speeds: if a reader is faster than the writer chances are that the pipe (read "bounded queue") never fills up. All that assumes concurrent reading and writing. That's where pipes are usually used. Cheers robert