Getting started with threads in D

Jonathan M Davis jmdavisProg at gmx.com
Sat Jun 16 19:22:58 PDT 2012


On Sunday, June 17, 2012 03:15:44 Henrik Valter Vogelius Hansson wrote:
> Hi again!
> 
> I have looked around a little with what D offers but don't know
> really what I should use since D offers several ways to use
> threads. Some more high level than others. Don't really also know
> which one would be suitable for me.
> 
> A little background could help. I am a game developer and during
> my semester I want to experiment with making games in D. I use
> threads to separate some tasks that can easily work in parallel
> with each other. The most common being a Logic/Graphics
> separation. But as development progresses I usually add more
> threads like inside graphics I can end up with 2 or 3 more
> threads.
> 
> I want to avoid Amdahl's law as much as possible and have as
> small synchronization nodes. The data exchange should be as basic
> as possible but still have room for improvements and future
> additions.
> 
> The Concurrency library looked very promising but felt like the
> synchronization wouldn't be that nice but it would provide a
> random-access to the data in your code. Correct me of course if I
> am wrong. Is there a good thread pool system that could be used?
> Does that system also handle solving dependencies in the
> work-flow? This is what we use at my work more or less.
> 
> In worst case scenario I will just use the basic thread class and
> implement my own system above that. Then there is the question,
> is there any pitfalls in the current library that I should be
> aware of?

For starters, read this:

http://www.informit.com/articles/article.aspx?p=1609144

And look at these modules in the standard library:

http://dlang.org/phobos/std_concurrency.html
http://dlang.org/phobos/std_parallelism.html

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list