First experience with Threads

Ali Çehreli acehreli at yahoo.com
Sat Oct 6 06:49:35 PDT 2012


On 10/06/2012 06:17 AM, Era Scarecrow wrote:
 > if the records and structures
 > never need to touch eachother, there's no reason they cannot be handled
 > on separate cores/threads (or that's my logic on it anyways).

Have you considered std.parallelism? If you can represent the data as a 
slice, then a parallel foreach loop on that data is all you need:

   foreach (data; parallel(dataSlice)) {
       // ... each data will be handled individually in parallel ...
   }

There is the following chapter about that module, which covers most of 
std.parallelism:

   http://ddili.org/ders/d.en/parallelism.html

Even though I have made a second pass to include the 
appearently-newly-added features, there are some features of 
std.parallelism that are missing in the chapter.

Although you don't seem to need it, there is also message passing 
concurrency:

   http://ddili.org/ders/d.en/concurrency.html

Ali



More information about the Digitalmars-d-learn mailing list