c954014.a

来自「linux下编程用 编译软件」· A 代码 · 共 486 行 · 第 1/2 页

A
486
字号
                  delay ImpDef.Minimum_Task_Switch;               end loop;               -- Indicate to the Main program that this section is complete               TC_Handshake_F.Set_True;            else               -- The main part of the test is complete. Send one Debit message               -- as further exercise of the Distributor to ensure it has not               -- been affected by the abort of the requeue;               Build_Debit_Record ( Next_Transaction );                           Next_Message_Task.Accept_Transaction ( Next_Transaction );              end if;         end;   -- declare      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Line_Driver");   end Line_Driver;      task body Message_Task is      TC_Original_Transaction_Code : Transaction_Code;        This_Transaction : acc_Transaction_Record := new Transaction_Record;   begin            accept Accept_Transaction (In_Transaction : acc_Transaction_Record) do         This_Transaction.all := In_Transaction.all;      end Accept_Transaction;            -- Note the original code to ensure correct return      TC_Original_Transaction_Code := This_Transaction.Code;                                                                        -- Queue up on Distributor's Input queue      Distributor.Input ( This_Transaction );      -- This task will now wait for the requeued rendezvous       -- to complete before proceeding                                                   -- After the required computations have been performed      -- return the Transaction_Record appropriately (probably to an output      -- line driver)      null;            -- stub            -- For the test check that the return values are as expected      if TC_Original_Transaction_Code /= This_Transaction.Code then         -- Incorrect rendezvous         Report.Failed ("Message Task: Incorrect code returned");      end if;      if This_Transaction.Code = Credit then         -- The only Credit message was the one that should have been aborted         Report.Failed ("Abort was not effective");      else         if This_Transaction.Return_Value     /= Debit_Return or               This_Transaction.TC_Message_Count /= 1            or not            This_Transaction.TC_Thru_Distrib       then               Report.Failed ("Expected path not traversed");         end if;         TC_Debit_Message_Complete.Set_True;      end if;   exception      when others =>          Report.Failed ("Unexpected exception in Message_Task");   end Message_Task;   -- Dispose each input Transaction_Record to the appropriate    -- computation tasks   --   task body Distributor is   begin      loop         select            accept Input (Transaction : acc_Transaction_Record) do               -- Indicate that the  message did pass through the               -- Distributor Task               Transaction.TC_Thru_Distrib := true;               -- Pass this transaction on the appropriate computation               -- task               case Transaction.Code is                   when Credit =>                     requeue Credit_Computation.Input;   -- without abort                  when Debit =>                      requeue Debit_Computation.Input;    -- without abort               end case;            end Input;         or            terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Distributor");   end Distributor;                                             -- Computation task.   --   Note:  After the computation is performed in this task and the    --          accept body is completed the rendezvous in the original   --          message task is completed.                                 task body Credit_Computation is      Message_Count   : integer := 0;   begin      loop         select             accept Input ( Transaction : acc_Transaction_Record) do               -- Perform the computations required for this transaction               --               null;     -- stub               -- The rest of this code is for Test Control               --               if not Transaction.TC_Thru_Distrib then                  Report.Failed                          ("Credit Task: Wrong queue, Distributor bypassed");               end if;               if Transaction.code /= Credit then                  Report.Failed                         ("Credit Task: Requeue delivered to the wrong queue");               end if;               -- for the test plug a known value and count               Transaction.Return_Value := Credit_Return;               -- one, and only one message should pass through               if Message_Count /= 0 then                  Report.Failed ("Aborted Requeue was not canceled -1");               end if;               Message_Count := Message_Count + 1;               Transaction.TC_Message_Count := Message_Count;                                       -- Having done the basic housekeeping we now need to signal               -- that we are in the accept body of the credit task.  The               -- message has arrived and the Line Driver may now abort the               -- calling task               TC_Handshake_A.Set_True;               -- Now wait for the Line Driver to inform us the calling                -- task has been aborted               while not TC_Handshake_B.Value loop                  delay ImpDef.Minimum_Task_Switch;               end loop;               -- The abort has taken place               -- Inform the Line Driver that we are still running in the               -- accept body               TC_Handshake_C.Set_True;               -- Now wait for the Line Driver to digest this information               while not TC_Handshake_D.Value loop                  delay ImpDef.Minimum_Task_Switch;               end loop;               -- The Line driver has checked that the caller is not terminated               -- We can now complete the accept                           end Input;            -- We are out of the accept            TC_Handshake_E.Set_True;                             or            terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Credit_Computation");   end Credit_Computation;   -- Computation task.   --   Note:  After the computation is performed in this task and the    --          accept body is completed the rendezvous in the original   --          message task is completed.                                 task body Debit_Computation is      Message_Count   : integer := 0;   begin      loop         select            accept Input (Transaction : acc_Transaction_Record) do               -- Perform the computations required for this message               --               null;      -- stub               -- The rest of this code is for Test Control               --               if not Transaction.TC_Thru_Distrib then                  Report.Failed                          ("Debit Task: Wrong queue, Distributor bypassed");               end if;               if Transaction.code /= Debit then                  Report.Failed                         ("Debit Task: Requeue delivered to the wrong queue");               end if;               -- for the test plug a known value and count               Transaction.Return_Value := Debit_Return;               -- one, and only one, message should pass through               Message_Count := Message_Count + 1;               Transaction.TC_Message_Count := Message_Count;            end Input;                     or            terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Debit_Computation");   end Debit_Computation;begin -- c954014   Report.Test ("C954014", "Abort a task that has a call" &                                          " requeued_without_abort");   Line_Driver.Start;   -- Start the test   -- Wait for the message tasks to complete before reporting the result   --   while not (TC_Handshake_F.Value                  -- abort not effective?              and TC_Debit_Message_Complete.Value   -- Distributor affected?              and TC_Handshake_E.Value ) loop       -- accept not completed?      delay ImpDef.Minimum_Task_Switch;   end loop;   Report.Result;end C954014;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?