GDC - program runs in one thread, DMD - in 4 threads, why?

bauss jj_1337 at live.dk
Fri Sep 10 12:59:08 UTC 2021


On Friday, 10 September 2021 at 12:46:36 UTC, eugene wrote:
> On Friday, 10 September 2021 at 12:10:58 UTC, Adam D Ruppe 
> wrote:
>> btw why do the threads cause you trouble?
>
> Well... probably it is subjective thing -
> just do not 'like' when a program is doing something
> that is not explicitly in it's source (I am C coder, you 
> guessed).
>
> More specifically - I have event driven state machine engine
> (reactor pattern, written in C), which I have been using
> over recent 5 years in various data acquisition and
> network client/servers programs. All these programs
> by their nature are single-threaded, since
> 'event/message driven' + 'state machines' combination gives me 
> very
> high-grained concurrency within single thread
> (and I don't like fibers/greenlets/coroutines).
>
> Recently I tried to re-implement that engine in D
> (I also tried Rust and C#, but D appeared to be less 
> 'problematic').
> I can give a link to sources of those echo-client/server pair
> if someone is interested (but there is a 'little' problem
> remained - when compliled with dmd, it sometimes crashes
> upon receiving SIGINT).

Well the program you're writing is still single-threaded.

The GC only uses the other threads when sweeping so the program 
flow will still be single-threaded and the exact same.

It's just used to speed-up the GC.


More information about the Digitalmars-d-learn mailing list