---------------------------------
-- D. Mathieu                  --
--                             --
-- fichier P_Tsk_BAO.adb       --
--                             --
-- créé le 13/12/98            --
--                             --
-- modifié le 28/12/98         -- ajout type T_BAL
--                             --
---------------------------------
--
with Ada.Text_IO, Ada.Task_Identification;
use  Ada.Text_IO, Ada.Task_Identification;

package body P_Tsk_BAO is

    package P_EditDuration is new Ada.Text_IO.Fixed_IO (Duration);
    use P_EditDuration;
    use Calendar;
 
    function Estampiller (Debut : in Time) return String is

    begin -- Estampiller

        return Duration'Image (Clock - Debut);

    end Estampiller;
 
    function S_Identifier return String is

    begin -- S_Identifier

        return Image (Current_Task);

    end S_Identifier;
 
    task body T_TskAffiche  is

    begin -- T_TskAffiche
 
        loop
            select
                accept JAffiche (Ligne : String) do
                   Put (Ligne);
                   New_Line;
                end JAffiche;
            or
                terminate;
            end select;
        end loop;
 
    end T_TskAffiche;
 
    protected body T_RDV is
 
        entry Arrive when True is

        begin -- Arrive
            NbreArrivés := NbreArrivés + 1;
            requeue Attendre;

        end Arrive ;
 
        entry Attendre when NbreArrivés = N is
 
        begin -- Attendre

            NbreRepartis := NbreRepartis + 1;
            if NbreRepartis = N
            then
                NbreArrivés  := 0;
                NbreRepartis := 0;
           end if;

        end Attendre;
 
    end T_RDV;

    protected body T_SemN is

        entry P when C > 0 is
 
        begin  -- P
            C := C - 1;
        end P;

        procedure V is
 
        begin -- V
            C := C + 1;
        end V;

        function  Count return Natural is
 
        begin -- Count
           return C;
        end Count;
 
    end T_SemN;

    package body P_BAL is
 
        protected body T_BAL is
 
            entry Deposer (LeMessage : in  T_Message) when not Plein is

            begin -- Deposer

                MessageLocal := LeMessage;
                Plein        := True;

            end Deposer;
 
            entry Retirer (LeMessage : out T_Message) when Plein is

            begin -- Retirer

                LeMessage := MessageLocal;
                Plein     := False;

            end Retirer;
 
        end T_BAL;
 
    begin -- P_BAL
 
        null;
 
    end P_BAL;

--begin -- P_Tsk_BAO
--    null;
end P_Tsk_BAO;