On 15.06.2010 00:45, Sean Kelly wrote:
stdin.byChunk uses a mutable buffer that's overwritten for each chunk so you
can't ask for an immutable ubyte[] in the foreach line. Here's the version of
that sample I used to test (13.7):
import std.algorithm, std.concurrency, std.stdio;
void main()
{
enum bufferSize = 10;
auto tid = spawn(&fileWriter );
// Read loop
foreach( ubyte[] buffer; stdin.byChunk( bufferSize ) )
send( tid, buffer.idup );
}
void fileWriter()
{
// Write loop
for( ; ; )
{
auto buffer = receiveOnly!(immutable(ubyte)[])();
writeln( "rx: ", buffer );
}
}
Right, now where's the bugzilla for TDPL? :)