You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

High Street Taxi/adb

From Wikitech-static
Jump to navigation Jump to search

/* Gagibda⁴ */

The High Street Taxi
High Street Taxi.adb
High Street.Taxi/index/adb

with ADA_Text.IO, use
ADA_Text.IO

 procedure Traffic is
            type Minibus_ID is
range 1..30
-30 Minibuses

    task type Minibus (ID:
Minibus_ID);     
   --task representing minibuses, with ID as initialisation parameter
        type Minibus_Access is
Access Minibus;        --reference type to Minibus
                 protect type Tyreroad

the shared tyre road
(protect to allow concurrent 
access)
                entry
Assign_High street (ID:
Minibus_ID) --all entries are mutually exclusive
                  enter cleared Tyre road
(ID: Minibus_ID);
                     entry
Wait_For_Clear:
        private
      Clear: Boolean:=
True:                       --protect private data           -generally more than just a flag...
            end Tyre road;
  type Tyre road access is
access all Tyre road;

     --the road traffic controller task takes request for Drive and Departure
      task type Controller
(My_Tyre_road: Tyre road_Access)
is
              --task entries for synchronous message passing
          entry
Request_Drive (ID: in Minibus_ID; Drive: out Tyre road_Access);
                       entry
Request_Approach (ID: in Minibus_ID; Approach: out Tyre road_Access);
          end Controller

           --allocation of instances
    Tyre road1 :aliased
Tyre road;                 --instantiate a tyre road
       Controller1: Controller
(Tyre road1 'Access);  --and a controller to manage it

           -------the implementations of the above types-------
         protected body Tyre road
is
         entry
Assign_High street (ID: Minibus_ID)
     when Clear is     --the entry guard -calling task are blocked until the conditions is true
              begin
              Clear:= False;
              Put_line
(Minibus_ID' Image (ID) & "on tyre road");
                 end;