parallelFuture

zsxxsz zhengshuxin at hexun.com
Thu Oct 22 01:07:40 PDT 2009


== Quote from dsimcha (dsimcha at yahoo.com)'s article
> I've created an alpha release of parallelFuture, a high-level parallelization
> library for D2.  Right now, it has a task pool, futures, parallel foreach, and
> parallel map.
> Here's the (IMHO) coolest example:
> auto pool = new ThreadPool();
> // Assuming we have a function isPrime(), print all
> // prime numbers from 0 to uint.max, testing for primeness
> // in parallel.
> auto myRange = iota(0, uint.max);
> foreach(num; pool.parallel(myRange)) {
>     if(isPrime(num)) {
>         synchronized writeln(num);
>     }
> }
> The interface is there and it seems to work, although it has not been
> extensively stress tested yet.  Some of the implementation details could
> admittedly use some cleaning up, and I would appreciate help from some
> threading gurus on improving my queue (right now it's a naive synchronized
> singly-linked list) and getting condition mutexes to work properly.  (Right
> now, I'm using atomic polling followed by sleeping for 1 millisecond in a lot
> of places.  It's a kludge, but it seems to work reasonably well in practice.)
> The code is at:
> http://dsource.org/projects/scrapple/browser/trunk/parallelFuture/parallelFuture.d
> The docs are at:
> http://cis.jhu.edu/~dsimcha/parallelFuture.html

Very good!


More information about the Digitalmars-d-announce mailing list