Bug 17127 – bad example code for std.concurrency.Generator

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-01-30T11:17:07Z
Last change time
2018-04-19T12:20:32Z
Keywords
pull
Assigned to
No Owner
Creator
ag0aep6g

Comments

Comment #0 by ag0aep6g — 2017-01-30T11:17:07Z
Found by Profile Anaysis who posted to D.learn: http://forum.dlang.org/post/[email protected] 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
Comment #1 by greensunny12 — 2017-07-12T16:27:37Z
Comment #2 by github-bugzilla — 2017-11-21T17:38:11Z
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 <[email protected]>
Comment #3 by github-bugzilla — 2017-11-21T20:19:33Z
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 <[email protected]>
Comment #4 by github-bugzilla — 2017-12-18T22:57:12Z
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
Comment #5 by greensunny12 — 2018-03-31T19:30:41Z
https://github.com/dlang/phobos/pull/5873 is the only bit left, but that's currently failing on 32-bit testers.
Comment #6 by github-bugzilla — 2018-04-18T15:00:22Z
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 <[email protected]>