On Fri, 2016-06-17 at 00:14 +0000, Moritz Maxeiner via Digitalmars-d- learn wrote: > So, I am probably overlooking something obvious, but here goes: > According to my understanding of daemon threads and what is > documented here[1], > this following program should terminate once the druntime shuts > down, as the thread working on the task is supposed to be a > daemon thread: > > > import std.parallelism; > > > > void main() > > { > > taskPool.put(task({ while(true) {} })); > > } > > The actual behaviour (with dmd 2.071 and ldc2 1.0.0), however, is > that the program keeps running.
A priori, assuming I am not missing anything, this behaviour seems entirely reasonable. The task is an infinite loop so it never terminates. This means the threadpool does not stop working, which means the program does not terminate. > In contract, this behaves as expected: > > > import core.thread; > > > > void main() > > { > > with (new Thread({ while(true) {} })) { > > isDaemon = true; > > start(); > > } > > } > > Commenting out setting the isDaemon property will achieve the > same behaviour as the taskPool example. Is this the intended > behaviour of taskPool (because it does have isDaemon set)? I suspect that daemon may not mean what you think it means. At least not with respect to the threadpool. > > [1] https://dlang.org/library/std/parallelism/task_pool.html -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part