Terminating multiple processes
Russel Winder
russel at winder.org.uk
Thu Feb 1 11:36:48 UTC 2018
On Wed, 2018-01-31 at 13:26 -0500, Steven Schveighoffer via
Digitalmars-d-learn wrote:
>
[…]
> You talking about processes or threads? `receive` I believe is an
> inter-thread channel, no?
These are threads with no shared memory, just message passing via
channels. I think of them as processes, but not OS processes. My poor
choose of names, I should just have said threads.
> Terminating processes is generally done via signals or in the case
> of
> windows, calling the right system call.
Indeed. usually SIGHUP or SIGTERM, but never SIGKILL.
> Threads are another story. Typically, you need to have the thread
> check
> periodically for a termination event. There's no "nice" way to do it
> out
> of band.
This is what I was fearing. Of course from a theoretical standpoint it
is the right way to do things.
> In my experience, the best way to do it is to never block, but use
> some
> sort of "wait on input" for any would-be-blocking operation. You can
> use
> a large timeout, like 1 second, if immediate termination isn't
> important.
The thread in question is usually blocked in an inotify wait state
having no input channel. It seems I will have to manufacture a select.
I think this is what is missing in D, or at least my knowledge of it.
In Go, I can set up a select between channels and block, no need for a
timeout, an input on either channel causes a wakeup. The code then has
to work out which channel caused the wakeup. On the other hand DInotify
doesn't provide a channel style blocking wait, so select isn't an
option.
> If you are using Fibers, and all your i/o is done using some event-
> based
> system (e.g. vibe.d), then things can be easier.
I am not sure I want to get into single-threaded event queues, but
maybe I should. I like the dataflow approach, it is simpler for me to
reason about.
--
Russel.
===========================================
Dr Russel Winder t: +44 20 7585 2200
41 Buckmaster Road m: +44 7770 465 077
London SW11 1EN, UK w: www.russel.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180201/6e7878a3/attachment.sig>
More information about the Digitalmars-d-learn
mailing list