Bug 10126 – Make TaskPool terminate on its own or improve docs to make it clear that it won't

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-21T01:00:03Z
Last change time
2019-11-15T23:28:34Z
Keywords
pull
Assigned to
No Owner
Creator
Jonathan M Davis

Comments

Comment #0 by issues.dlang — 2013-05-21T01:00:03Z
This program will never exit: import std.parallelism; import std.stdio; void main() { auto pool = new TaskPool; writeln("Exiting..."); } It prinst "Exiting..." and then just sits there. After poking at this for a couple of hours, I finally figured out that you have to call finish on the TaskPool to get it to terminate. My first inclination is that the threads should properly terminate when the main thread terminates and that it's a bug that they don't, but it may very well be that they have to work that way for one reason or another. But the docs are _not_ clear on this point. After digging through the docs in std.parallelism, I see some mention in stuff like taskPool of needing to call finish normally, but the main TaskPool docs say nothing of the sort. So, please either make it so that the TaskPool's threads terminate when main does or clarify TaskPool's documentation so that the correct usage is clear. There probably needs to be an example on TaskPool on its proper usage so that it's clear that finish needs to be called (as well as any other quirks of which I'm not aware). Otherwise, it's too easy to miss them and end up with a program that won't terminate for no obvious reason.
Comment #1 by dlang-bot — 2019-11-14T13:12:06Z
@berni44 created dlang/phobos pull request #7275 "Fix Issue 10126 - Make TaskPool terminate on its own or improve docs" fixing this issue: - Fix Issue 10126 - Make TaskPool terminate on its own or improve docs https://github.com/dlang/phobos/pull/7275
Comment #2 by dlang-bot — 2019-11-15T23:28:34Z
dlang/phobos pull request #7275 "Fix Issue 10126 - Make TaskPool terminate on its own or improve docs" was merged into master: - 170107cc149b0f2afb559a40f017c70d7a9789ba by Bernhard Seckinger: Fix Issue 10126 - Make TaskPool terminate on its own or improve docs https://github.com/dlang/phobos/pull/7275