------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 199x by International Computer Science Institute            --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------

class TEST_DOOR is
   include R_TEST;

   o(br:DOOR_LOCK,g:GATE) is
      #OUT+(THREAD_ID::me.str+": o started\n");
      lock when br.open then
      #OUT+(THREAD_ID::me.str+": o got lock\n");
         test("open",g.size,1);
      #OUT+(THREAD_ID::me.str+": o test done\n");
      end;
      #OUT+(THREAD_ID::me.str+": o done\n");
   end;

   c(br:DOOR_LOCK,g:GATE) is
      #OUT+"started\n";
      lock when br.close then
         #OUT+"got lock\n";	
         test("close",g.size,2);
      end;
      #OUT+"done\n";
   end;

   main is
      i:INT;
      class_name("DOOR_LOCK");
      br::=#DOOR_LOCK;
      a::=#ATTACH;
      g::=#GATE;
      test("is_open",br.is_open,false);
      test("is_close",br.is_closed,true);

      loop a:-o(br,g)@clusters!; end;
      TIMING::sleep(1);
	-- wait until all start
      -- loop
      	 -- i:=1.upto!(clusters);
         -- s.wait;
       -- end;	

      g.enqueue;
      br.open_door;
      test("is_open",br.is_open,true);
      test("is_close",br.is_closed,false);

      lock when a.no_threads then end;
      #OUT+"all threads have stopped\n";

      g.enqueue;
      #OUT+"value enqueued\n";

      loop a:-c(br,g)@clusters!; end;
--      br.close_door;
--      #OUT + "Closed door\n";	
--      lock when a.no_threads then end;
      finish;
   end;
end; 

-------------------------------------------------------------------
