On Mon, 05 Dec 2011 23:36:27 +0200, Jonas Drewsen <jdrew...@nospam.com> wrote:

It is - but as stated it all depends on buffer sizes and IO speed. It is for the same reason that java recommends using BufferedReader around sockets instead of reading directly from the socket stream.

Another example that might show another async range advantage and is clearer:

auto f1 = byChunkAsync("www.foo.com/file1.txt", 2^^19);
auto f2 = byChunkAsync("www.foo.com/file2.txt", 2^^19);
auto f3 = byChunkAsync("www.foo.com/file3.txt", 2^^19);

// While this iteration goes is done the file2 and file3 are downloaded
// in the background threads
foreach (l; f1) { writeln(to!string(l)); }

// f2 and f3 are probably downloaded now and no waiting is necessary
foreach (l; f2) { writeln(to!string(l)); }
foreach (l; f3) { writeln(to!string(l)); }

Thanks. Perhaps include this example in the documentation?

--
Best regards,
 Vladimir                            mailto:vladi...@thecybershadow.net

Reply via email to