|
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: 5120 (0x1400) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, procedure Task_Main_Example, seg_0583ff
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─⟦cfc2e13cd⟧ »Space Info Vol 2« └─⟦this⟧
with Task_Main_Support; with Task_Code_Wrapper; procedure Task_Main_Example is type Operand_Type is range 0 .. 1_000_000; -- whatever.... function Some_Function (What : in Operand_Type) return Operand_Type; package Ops is new Task_Code_Wrapper (Operand => Operand_Type, Operate => Some_Function); type Operator_List is array (Operand_Type range <>) of Ops.Operator; -- Declare a list of tasks that will do the work. List : Operator_List (1 .. 10); Find : Operand_Type; -- temporary variable... procedure Print (Text : in String) renames Task_Main_Support.Print; function Some_Function (What : in Operand_Type) return Operand_Type is begin delay 1.0; -- simulate an action that takes a long time, but -- that can run simultaneously with other actions. return What * 2; end Some_Function; begin Print ("At start."); -- First give all 10 running tasks a value to work on. for Fill in List'Range loop Ops.Startup (List (Fill), Fill); end loop; Print ("After all initialized."); -- At this point, all tasks are running on their respective values. -- Get results from each task when ready ... for Fill in List'Range loop Ops.Results (List (Fill), Find); Print ("Result (" & Operand_Type'Image (Fill) & " ) =>" & Operand_Type'Image (Find)); end loop; Print ("All done."); end Task_Main_Example; pragma Main; -- Sample Output => -- -- Time 0.010: At start. -- Time 0.020: After all initialized. -- Time 1.020: Result( 1 ) => 2 -- Time 1.020: Result( 2 ) => 4 -- Time 1.020: Result( 3 ) => 6 -- Time 1.020: Result( 4 ) => 8 -- Time 1.030: Result( 5 ) => 10 -- Time 1.030: Result( 6 ) => 12 -- Time 1.030: Result( 7 ) => 14 -- Time 1.030: Result( 8 ) => 16 -- Time 1.030: Result( 9 ) => 18 -- Time 1.030: Result( 10 ) => 20 -- Time 1.040: All done. -- -- (note that without tasking, this would have taken at least 10 seconds)
nblk1=4 nid=4 hdr6=6 [0x00] rec0=1f rec1=00 rec2=01 rec3=02a [0x01] rec0=1f rec1=00 rec2=03 rec3=02a [0x02] rec0=06 rec1=00 rec2=02 rec3=000 [0x03] rec0=06 rec1=00 rec2=02 rec3=000 tail 0x21765a18887e37844cfd8 0x42a00088462060003 Free Block Chain: 0x4: 0000 00 00 00 04 80 01 6c 01 02 03 04 05 06 07 05 62 ┆ l b┆