ACCU 2013 and D

angel andrey.gelman at gmail.com
Mon Jan 21 00:26:55 PST 2013


Concurrency and parallelism may be emphasized well with this 
simple example:

     foreach(i, ref elem; task_pool.parallel(logs)) {
         elem = log(i + 1.0);
     }

Keeping the (straight forward) serial semantics, we write 
parallelizable code.

Another good example, that demonstrates concurrency model 
borrowed from Erlang is:

     while (cont) {
         receive(
             (int msg) { writeln("int received: ", msg) },
             (string msg) {
                 cont = (msg == "stop") ? false : true;
             }
         );
     }

The 'send' part you can easily add by yourself.

Both examples emphasize requiring little and giving much.


More information about the Digitalmars-d mailing list