|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 10240 (0x2800) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Connection_Manager_Generic, seg_00f325
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─⟦cfc2e13cd⟧ »Space Info Vol 2« └─⟦this⟧
with Calendar; with String_Map_Generic; package body Connection_Manager_Generic is use Calendar; -- operators everywhere task Manager is entry Close_All_Connections; entry Shutdown; entry Close_Connection (Destination : String); entry Operate (Object : Object_Id; Parms : in out Operate_Parameters; Errors : in out Simple_Status.Condition); end Manager; task body Manager is Operating : Boolean := True; Duration_To_Next_Timeout : Duration := 0.0; subtype Connection_Id is Natural range 0 .. Max_Connections; Null_Connection_Id : constant Connection_Id := 0; type Connection_Info is record Handle : Connection_Handle; Last_Use : Calendar.Time; Idle_Timeout : Duration; In_Use : Boolean; end record; package Smap is new String_Map_Generic (Size => 101, Range_Type => Connection_Id); Map : Smap.Map; type Connection_Array is array (Connection_Id) of Connection_Info; Connections : Connection_Array; procedure Next_Interval_Setup is -- find shortest timeout interval Timeout_Time : Calendar.Time; Timeout_Duration : Duration; begin Duration_To_Next_Timeout := Duration'Large; for I in Connections'Range loop if Connections (I).In_Use and then Connections (I).Idle_Timeout < Duration'Large then Timeout_Time := Calendar."+" (Connections (I).Last_Use, Connections (I).Idle_Timeout); Timeout_Duration := Calendar."-" (Timeout_Time, Calendar.Clock); -- *** need to handle constraint error for the above if Timeout_Duration < Duration_To_Next_Timeout then Duration_To_Next_Timeout := Timeout_Duration; end if; end if; end loop; end Next_Interval_Setup; procedure Do_Operate (Object : Object_Id; Parms : in out Operate_Parameters; Errors : in out Simple_Status.Condition) is Destination : constant String := Get_Destination (Object); Cid : Connection_Id := Null_Connection_Id; Free_Cell : Connection_Id := Null_Connection_Id; Found : Boolean; begin Smap.Find (Map, Destination, Cid, Found); -- search connections for one: if not Found then Cid := Null_Connection_Id; for I in Connections'First + 1 .. Connections'Last loop if Connections (I).In_Use = False then Cid := I; exit; end if; end loop; -- allocate a new connection id if Cid = Null_Connection_Id then -- none available Simple_Status.Create_Condition (Errors, "No_Connections_Available"); return; else -- form connection Open (Destination, Object, Connections (Cid).Handle, Connections (Cid).Idle_Timeout, Errors); if Simple_Status.Error (Errors) then return; end if; Connections (Cid).In_Use := True; Connections (Cid).Last_Use := Calendar.Clock; Smap.Define (Map, Destination, Cid); Next_Interval_Setup; end if; end if; -- Now, do the operation Operate (Connections (Cid).Handle, Parms, Errors); Connections (Cid).Last_Use := Calendar.Clock; end Do_Operate; procedure Close_Connection (Cid : Connection_Id) is Errors : Simple_Status.Condition; Iter : Smap.Iterator; begin if Connections (Cid).In_Use then Close (Connections (Cid).Handle, Errors); Connections (Cid).In_Use := False; -- remove any map entries that point to it. Smap.Init (Iter, Map); while not Smap.Done (Iter) loop if Smap.Eval (Map, Smap.Value (Iter)) = Cid then Smap.Undefine (Map, Smap.Value (Iter)); Next_Interval_Setup; end if; Smap.Next (Iter); end loop; end if; end Close_Connection; procedure Do_Close_Connection (Destination : String) is Found : Boolean; Cid : Connection_Id; begin Smap.Find (Map, Destination, Cid, Found); if Found then Close_Connection (Cid); end if; end Do_Close_Connection; procedure Do_Close_All_Connections is begin for I in Connections'Range loop if Connections (I).In_Use then Close_Connection (I); end if; end loop; -- Remove any entries from map Smap.Make_Empty (Map); Next_Interval_Setup; end Do_Close_All_Connections; begin Smap.Initialize (Map); Next_Interval_Setup; while Operating loop while Operating loop begin select accept Close_All_Connections do Do_Close_All_Connections; end Close_All_Connections; or accept Shutdown do Operating := False; end Shutdown; or accept Close_Connection (Destination : String) do Do_Close_Connection (Destination); end Close_Connection; or accept Operate (Object : Object_Id; Parms : in out Operate_Parameters; Errors : in out Simple_Status.Condition) do Do_Operate (Object, Parms, Errors); end Operate; or delay Duration_To_Next_Timeout; -- loop over connections and close'em for I in Connections'Range loop if Connections (I).In_Use and then Calendar."+" (Connections (I).Last_Use, Connections (I).Idle_Timeout) < Calendar.Clock then -- time out has occurred Close_Connection (I); end if; end loop; end select; exception when others => null; end; end loop; end loop; end Manager; procedure Operate (Object : Object_Id; Parms : in out Operate_Parameters; Errors : in out Simple_Status.Condition) is begin Manager.Operate (Object, Parms, Errors); end Operate; procedure Close_Connection (Destination : String) is begin Manager.Close_Connection (Destination); end Close_Connection; procedure Close_All_Connections is begin Manager.Close_All_Connections; end Close_All_Connections; procedure Shutdown is begin Manager.Shutdown; end Shutdown; end Connection_Manager_Generic;
nblk1=9 nid=0 hdr6=12 [0x00] rec0=21 rec1=00 rec2=01 rec3=030 [0x01] rec0=13 rec1=00 rec2=02 rec3=066 [0x02] rec0=15 rec1=00 rec2=03 rec3=050 [0x03] rec0=16 rec1=00 rec2=04 rec3=02e [0x04] rec0=19 rec1=00 rec2=05 rec3=028 [0x05] rec0=20 rec1=00 rec2=06 rec3=068 [0x06] rec0=14 rec1=00 rec2=07 rec3=056 [0x07] rec0=1a rec1=00 rec2=08 rec3=000 [0x08] rec0=11 rec1=00 rec2=09 rec3=000 tail 0x2170bb8b4822a65b52c96 0x42a00088462060003