On Friday, 11 October 2019 at 06:18:03 UTC, Ali Çehreli wrote:
Your threads must allocate as little memory as possible because memory allocation can trigger garbage collection and garbage collection stops all threads (except the one that's performing collection). We studied the effects of different allocation schemes during our last local D meetup[1]. The following program has two similar worker threads. One allocates in an inner scope, the other one uses a static Appender and clears its state as needed. The static Appender is thread-safe because each thread gets their own copy due to data being thread-local by default in D. However, it doesn't mean that the functions are reentrant: If they get called recursively perhaps indirectly, then the subsequent executions would corrupt previous executions' Appender states.

Thanks for the information, they were very helpful.

Reply via email to