1. with Ada.Exceptions; use Ada.Exceptions; 
  2. with Ada.Text_IO;    use Ada.Text_IO; 
  3. with Hold_when_Busy; use Hold_when_Busy; 
  4.  
  5. package body Calculation_Nodes is 
  6.  
  7.    use Complex_Types; 
  8.  
  9.    task body Compute_Node is 
  10.  
  11.    begin 
  12.       loop 
  13.          select 
  14.             accept Responsive; 
  15.          or 
  16.             accept Compute (Job : Jobs; Diverge_Column : out Natural_Array) do 
  17.                declare 
  18.                   Divergent : constant Real := 2.0; 
  19.                begin 
  20.                   Busy_Nodes.Inc; 
  21.                   for y in Diverge_Column'Range loop 
  22.                      declare 
  23.                         C : constant Complex := Job.Origin + (Re => 0.0, Im => Real (y) * Job.Resolution); 
  24.                         Z :          Complex := C; 
  25.                      begin 
  26.                         Diverge_Column (y) := Divergence_Limit; 
  27.                         Iterate : for Iteration in 0 .. Divergence_Limit loop 
  28. --                             if abs (Z) > Divergent then -- earlier cutoff, yet slower to evaluate 
  29.                            if abs (Z.Re) > Divergent or else abs (Z.Im) > Divergent then 
  30.                               Diverge_Column (y) := Iteration; 
  31.                               exit Iterate; 
  32.                            end if; 
  33.                            Z := C + Z ** 2; 
  34.                         end loop Iterate; 
  35.                      end; 
  36.                   end loop; 
  37.                   Busy_Nodes.Dec; 
  38.                end; 
  39.             end Compute; 
  40.          or 
  41.             terminate; 
  42.          end select; 
  43.       end loop; 
  44.    exception 
  45.       when E : others => Put_Line (Exception_Information (E)); 
  46.    end Compute_Node; 
  47.  
  48. end Calculation_Nodes;