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
signature.asc
Description: This is a digitally signed message part