[M3devel] join twice?

Jay K jay.krell at cornell.edu
Mon Nov 2 16:11:28 CET 2009


Thread.i3:

 

 

PROCEDURE Join(t: T): REFANY;
(* Wait until "t" has terminated and return its result. It is a
   checked runtime error to call this more than once for any "t". *)


 

ThreadWin32.m3:

 

 

PROCEDURE Join(t: T): REFANY =
  VAR res: REFANY;
  BEGIN
    LOCK t DO
      IF t.joined THEN Die(ThisLine(), "attempt to join with thread twice"); END;
      WHILE NOT t.completed DO Wait(t, t.join) END;
      res := t.result;
      t.result := NIL;
      t.joined := TRUE;
      t.join := NIL;
    END;
    RETURN res;
  END Join;

 

PROCEDURE AlertJoin(t: T): REFANY RAISES {Alerted} = similar



ThreadPThread.m3:

 


PROCEDURE Join (t: T): REFANY =
  BEGIN
    LOCK t DO
      WHILE NOT t.completed DO Wait(t, t.join) END;
    END;
    RETURN t.result;
  END Join;

 

PROCEDURE AlertJoin (t: T): REFANY RAISES {Alerted} = similar


 

Should we just loosen the comment and go with the simpler pthread version?

I'd like Win32 and pthread to be more similar where possible, to ease maintenance.

 

 

 - Jay
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20091102/c64ca67d/attachment-0001.html>


More information about the M3devel mailing list