Threading Question

Alex Rønne Petersen alex at lycus.org
Thu Oct 25 16:12:27 PDT 2012


On 26-10-2012 01:11, Sean Kelly wrote:
> On Oct 23, 2012, at 11:25 AM, Peter Sommerfeld <noreply at rubrica.at> wrote:
>
>> Hi!
>>
>> I'm new to D an not a native speaker so I may misunderstand
>> the following sentence of the thread documentation.
>>
>> "final @property void isDaemon(bool val);
>>
>> Sets the daemon status for this thread. While the runtime
>> will wait for all normal threads to complete before tearing
>> down the process, daemon threads are effectively ignored and
>> thus will not prevent the process from terminating. In effect,
>> daemon threads will be terminated automatically by the OS when
>> the process exits."
>>
>> That sounds to me as if the daemon will be finished when the
>> main-thread has finished. But in my understanding daemons will
>> survive the termination of the main-thread and be killed by
>> a signal (KILL, SIGTERM etc) or finish itself.
>>
>> I think that is the case here too. Is that true ?
>
> In D, the main thread will join all non-daemon threads before calling static dtors or performing any other cleanup.  Daemon threads will continue to run until the process exits.  So daemon threads are basically just C-style kernel threads.
>
>
>> Another question: I cannot find a reference how D deals with
>> OS SIGNALS, especially about differences between the platform
>> (*nix; Windows, Mac). Can you explain or point me to the
>> documentation?
>
> The GC in D uses SIGUSR1 and SIGUSR2 to coordinate collections on Posix OSes (except for OSX).  You're free to use any other signal just as you would in C.
>

What's used on OS X? I forget...

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d-learn mailing list