Found by Profile Anaysis who posted to D.learn: http://forum.dlang.org/post/vlvqmzrfvqmxzsfxpslu@forum.dlang.org The example code for std.concurrency.Generator [1] throws an OwnerTerminated exception. The code: ---- import std.concurrency; import std.stdio; void main() { auto tid = spawn( { while (true) { writeln(receiveOnly!int()); } }); auto r = new Generator!int( { foreach (i; 1 .. 10) yield(i); }); foreach (e; r) { tid.send(e); } } ---- The exception gets thrown because the spawned thread still tries to receive ints after the main thread has finished. The example code should be fixed. [1] https://dlang.org/library/std/concurrency/generator.html
https://github.com/dlang/phobos/pull/5603
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/5df663ead1203dea2fd7cbaae189bae99c1eafec Issue 17127 - bad example code for std.concurrency.Generator https://github.com/dlang/phobos/commit/a7953301bcbbb416cfcf2d35d3c1647e99a82ee9 Merge pull request #5872 from wilzbach/std-concurrency-tests-1 Issue 17127 - bad example code for std.concurrency.Generator merged-on-behalf-of: Jack Stouffer <jack@jackstouffer.com>
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/d2e716b20ed571ac00e184cdb84a0c158c5136c9 Issue 17127 - bad example code for std.concurrency.Generator https://github.com/dlang/phobos/commit/4e197f22630329bc44203b72712cb43020fd710e Merge pull request #5870 from wilzbach/std-concurrency-tests-2 Issue 17127 - bad example code for std.concurrency.Generator merged-on-behalf-of: Jack Stouffer <jack@jackstouffer.com>
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/d2e716b20ed571ac00e184cdb84a0c158c5136c9 Issue 17127 - bad example code for std.concurrency.Generator https://github.com/dlang/phobos/commit/5df663ead1203dea2fd7cbaae189bae99c1eafec Issue 17127 - bad example code for std.concurrency.Generator https://github.com/dlang/phobos/commit/a7953301bcbbb416cfcf2d35d3c1647e99a82ee9 Merge pull request #5872 from wilzbach/std-concurrency-tests-1 https://github.com/dlang/phobos/commit/4e197f22630329bc44203b72712cb43020fd710e Merge pull request #5870 from wilzbach/std-concurrency-tests-2
https://github.com/dlang/phobos/pull/5873 is the only bit left, but that's currently failing on 32-bit testers.
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/903c38d7bb4e6ecad86f75ba444737de91fd8078 Issue 17127 - bad example code for std.concurrency.Generator https://github.com/dlang/phobos/commit/abba3388dc91b990bd9d208cb1fae3d58e6d5be0 Merge pull request #5873 from wilzbach/std-concurrency-tests-4 Issue 17127 - bad example code for std.concurrency.Generator merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>