Concurrency Confusion
"岩倉 澪" via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Aug 6 14:17:13 PDT 2015
On Tuesday, 4 August 2015 at 08:35:10 UTC, Dicebot wrote:
> // in real app use `receiveTimeout` to do useful stuff until
> // result message is received
> auto output = receiveOnly!(immutable(Bar)[]);
New question: how would I receive a immutable value with
receiveTimeout? I need the results from my worker thread outside
of the delegate that receiveTimeout takes.
Also: what is the best way to kill off the worker thread when I
close the application, without having to wait for the worker
thread to complete? My first thought was to use receiveTimeout in
the worker thread, but the work is being done in a parallel
foreach loop, and I am not sure if there is a way to safely use
receiveTimeout in a parallel situation...
I also found Thread.isDaemon in core.thread. I tried doing auto
thread = Thread.getThis(); thread.isDaemon = true; at the start
of the worker thread, but it still seems to wait for it to
complete before closing.
Thanks again!
More information about the Digitalmars-d-learn
mailing list