Nick Sabalausky wrote:
[snip]
It's been no worse at threading than C/C++ for quite some time. It's just starting to have a threading model that kicks the crap out of the threading in the vast majority of languages out there.

BTW, that effort is going quite well. For example, a producer-consumer file copy program using the proposed API has 20 lines, correctness and all.

import std.algorithm, std.concurrency, std.stdio;

void main() {
   enum bufferSize = 1024 * 100;
   auto tid = spawn(&writer);
   // Read loop
   auto src = stdin.by!(ubyte)();
   for (;;) {
      auto buffer = UniqueArray!(ubyte)(bufferSize);
      auto length = copy(take(src, bufferSize), buffer).length;
      send(tid, move(buffer));
      if (length == 0) break;
   }
}

void writer() {
   // Write loop
   auto tgt = stdout.by!(ubyte)();
   for (;;) {
      auto buffer = receiveOnly!(UniqueArray!ubyte)();
      copy(buffer, tgt);
   }
}


Andrei

Reply via email to