[Issue 7446] New: [TDPL] Trivial asynchronous file copy example crashes with OwnerTerminated
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 5 14:56:15 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7446
Summary: [TDPL] Trivial asynchronous file copy example crashes
with OwnerTerminated
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: TDPL
Severity: normal
Priority: P2
Component: druntime
AssignedTo: nobody at puremagic.com
ReportedBy: thecybershadow at gmail.com
--- Comment #0 from Vladimir Panteleev <thecybershadow at gmail.com> 2012-02-05 14:56:13 PST ---
import std.concurrency, std.stdio;
void main() {
enum bufferSize = 1024 * 100;
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)[])();
stdout.rawWrite(buffer);
}
}
TDPL says: "The writer thread exits with the OwnerTerminated exception, which
is recognized by the runtime system, which simply ignores it."
This program will cat stdin to stdout as expected, however on exit it will
apparently crash with an OwnerTerminated exception.
I should point out another oddity: the exception information (class, message,
stack trace) are printed to STDOUT, not STDERR. When using this example program
to copy a file using pipes, the exception is appended to the destination file.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list