Atomicity of Cells

Christopher Campbell campbell at dcs.gla.ac.uk
Mon Jan 17 14:34:21 CET 2005


Hi,

Exchange is atomic on cells, what about '@' and Cell.access?  I am 
writing some code that processes one task at a time incoming on a stream 
that must shutdown on after completing one task but before beginning 
another.  The task execution unit is only given a future to the stream. 
  My initial thought was to use a lock guarding the cell, but I was 
wondering if atomicity is guaranteed for reading of cells as in the 
following.


    proc {NewTaskUnit Log Name TaskStream ?TU}

       ToShutdown

       proc {Shutdown}
	 {Exchange ToShutdown _ true}
       end
    in
       {NewCell false ToShutdown}
       thread
	 try
	    for T in TaskStream do
	       if @ToShutdown == false then
		  try		
		     {Log log(message: "Agent <"#Name#">: Beginning Task...")}
		     {DoTask T}
		     {Log log(message: "Agent <"#Name#">: Task completed.")}		
		  catch unknownTask then
		     {Log log(message: "Agent <"#Name#">: Unknown task type")}
		  [] E then
		     {Log log(message: "Agent <"#Name#">: Unknown error...\n\n"#E)}
		  end
	       else
		  raise exitLoopNow end
	       end	
	    end
	 catch
	    endLoopNow then
	    skip % exit loop.
	 [] E then
	    skip % what now?
	 end
       end

       TU = taskUnit(shutdown: Shutdown)
    end


Regards,
Chris



More information about the mozart-users mailing list