c954015.a

来自「Mac OS X 10.4.9 for x86 Source Code gcc」· A 代码 · 共 550 行 · 第 1/2 页

A
550
字号
            This_Transaction.TC_Thru_Distrib       then               Report.Failed ("Expected path not traversed - CR");         end if;         if             This_Transaction.TC_Message_Count not in 1..2 then               Report.Failed ("Incorrect Message Count");         end if;      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 - DB");         end if;      end if;      TC_Tasks_Completed.Increment;   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               -- Show that the message did pass through the Distributor Task               Transaction.TC_Thru_Distrib := true;               -- Pass this transaction on to the appropriate computation               -- task               case Transaction.Code is                   when Credit =>                     requeue Credit_Computation.Input with abort;                  when Debit =>                      requeue Debit_Computation.Input with 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 the message is   --   passed on for further processing to some subsidiary task.  The choice   --   of subsidiary task is made according to criteria not specified in   --   this test.     --                                              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               -- For the test:                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 := TC_Credit_Value;               Message_Count := Message_Count + 1;               Transaction.TC_Message_Count := Message_Count;               -- Depending on transaction content send it on to the               -- some other task for further processing               -- TC: Arbitrarily send the message on to Credit_Sub_1               requeue Credit_Sub_1.Input with abort;            end Input;                     or            terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Credit_Computation");   end Credit_Computation;   task body Credit_Sub_1 is   begin      loop         select            accept Input(Transaction : acc_Transaction_Record) do               -- Process this transaction               null;   -- stub                           -- Add the value showing passage through this task               Transaction.Return_Value :=                                     Transaction.Return_Value + TC_Sub_1_Value;               -- Depending on transaction content send it on to the               -- some other task for further processing               -- Arbitrarily send the message on to Credit_Sub_2               requeue Credit_Sub_2.Input with abort;              end Input;         or             terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Credit_Sub_1");   end Credit_Sub_1;   task body Credit_Sub_2 is   begin      loop         select            accept Input(Transaction : acc_Transaction_Record) do               -- Process this transaction               null;   -- stub                           -- Add the value showing passage through this task               Transaction.Return_Value :=                                     Transaction.Return_Value + TC_Sub_2_Value;               -- Depending on transaction content send it on to the               -- some other task for further processing               -- Arbitrarily send the message on to Credit_Sub_3               requeue Credit_Sub_3.Input with abort;              end Input;         or             terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Credit_Sub_2");   end Credit_Sub_2;   task body Credit_Sub_3 is   begin      loop         select            accept Input(Transaction : acc_Transaction_Record) do               -- Process this transaction               null;   -- stub                           -- Add the value showing passage through this task               Transaction.Return_Value :=                                     Transaction.Return_Value + TC_Sub_3_Value;               -- Depending on transaction content send it on to the               -- some other task for further processing               -- Arbitrarily send the message on to Credit_Sub_4               requeue Credit_Sub_4.Input with abort;              end Input;         or             terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Credit_Sub_3");   end Credit_Sub_3;   -- This is the last in the chain of tasks to which transactions will   -- be requeued   --   task body Credit_Sub_4 is         TC_First_Message : Boolean := true;   begin      loop         select            accept Input(Transaction : acc_Transaction_Record) do               -- Process this transaction               null;   -- stub                           -- Add the value showing passage through this task               Transaction.Return_Value :=                                     Transaction.Return_Value + TC_Sub_4_Value;               -- TC: stay in the accept body dealing with the first message               -- until the second arrives.  If any of the requeues are                -- blocked the test will hang here indicating failure               if TC_First_Message then                  while Input'count = 0 loop                     delay ImpDef.Minimum_Task_Switch;                  end loop;               TC_First_Message := false;               end if;               -- for the second message, just complete the rendezvous            end Input;         or             terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Credit_Sub_4");   end Credit_Sub_4;                                                   -- 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               -- For the test:                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    Report.Test ("C954015", "Test multiple levels of requeue to task entry");   Line_Driver.Start;  -- Start the test   -- Ensure that the message tasks completed before calling Result   while (TC_Tasks_Completed.Count < TC_Expected_To_Complete) loop      delay ImpDef.Minimum_Task_Switch;   end loop;   Report.Result;end C954015;

⌨️ 快捷键说明

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