Determination of thread status.
Vitaly
gkvetal at gmail.com
Wed Dec 26 05:43:47 UTC 2018
On Tuesday, 25 December 2018 at 17:08:00 UTC, Neia Neutuladh
wrote:
> 1. Find the Thread object:
> Tid threadId = spawn(&doStuff);
> auto thread = Thread.getAll.filter!(x => x.id ==
> threadId).front;
> 2. Check the `isRunning` property.
>
> The indirection with spawn() is awkward.
Thanks for the answer.
I checked.
Thread.getAll [x] .id is of type ulong, and spawn is of type Tid,
moreover, they do not intersect in value either. But even if the
program spawns a single thread, Thread.getAll [x] .isRunning
returns true after the function terminates. Perhaps you need to
wait some time.
You may have to send a message before exiting the function. Just
look at the possibilities of std.parallelism.
I will gladly try other solutions. I would be grateful for your
suggestions.
More information about the Digitalmars-d-learn
mailing list