Hacker News new | past | comments | ask | show | jobs | submit login

almost like erlang (http://dlang.org/)

  import std.stdio;
  import std.concurrency;

  void world() {
    bool running = true;
    while (running) {
      receive(
        (Tid finished) { writeln("World"); send(finished, true); },
        (OwnerTerminated e) { running = false; }
      );
    }
  }
  void hello(Tid world, Tid finished) {
    for (int i=0; i<1000; i++) {
      write("Hello ");
      send(world, thisTid);
      receiveOnly!(bool)();
    }
    send(finished, true);
  }
  int main(string[] args) {
    auto world = spawn(&world);
    auto hello = spawn(&hello, world, thisTid);
    receiveOnly!(bool)();
    return 0;
  }



Applications are open for YC Winter 2021

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: