Comment by pjmlp

5 years ago

You can do a round over here,

https://freepages.modula2.org/compi.html

As for Ada tasks, https://learn.adacore.com/courses/intro-to-ada/chapters/task...

As someone who doesn't know Ada very well: Ada 'tasks' look like ordinary threads but with integrated message pumps. Is that about right?

  • There's a bit more to it.

    I think one of the more novel (hah! 40 years old now) aspects is that tasks can be declared on the stack which allows for structured concurrency to be done in Ada without needing a separate library. Something like (outline):

      package body SomethingSomethingDarkside is
        procedure Foo(N : Integer) is
          task A ...
          task B ...
          task C ...
          task type D ...
    
          Bunch_Of_Ds : array (1..N) of D;
        begin
          DoStuff;
        end Foo; -- doesn't actually terminate until all the above terminate
      begin
        Foo;
        Put_Line("Won't be printed until after all of Foo's tasks finish.");
      end SomethingSomethingDarkside; -- 
    

    Neatly fits the intention of Structured Concurrency. Tasks can also be allocated on the heap which allows you to have something more like what conventional threads or Go routines or Erlang processes do.

    And protected objects come with built in mutexes and blocking conditions on entries to prevent race conditions or control system invariants.

    https://en.wikipedia.org/wiki/Structured_concurrency