DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦4a453b250⟧ Ada Source

    Length: 11264 (0x2c00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, seg_0217d3

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



WITH Byte_Defs;
WITH Transport;
WITH Transport_Defs;

PACKAGE Transport_Stream IS

   -- A transport stream combines a transport.connection with
   -- some buffering, and provides a simplified transmit/receive
   -- interface.

   -- A facility is provided for creating pools of streams.
   -- Allocating and deallocating streams is usually fast.
   -- Unused streams are scavenged periodically.

   -- This package is useful for programs which want to communicate
   -- with some other machine, but don't want to be bothered with
   -- setting up and tearing down transport.connections, or don't
   -- want to deal with transport status codes.


   TYPE Stream_Id IS PRIVATE;


   PROCEDURE Allocate (Stream     : OUT Stream_Id;
                       Connection :     Transport.Connection_Id);

   -- Create a stream around the given connection.  Such a
   -- stream has no pool, and will be closed as soon as it
   -- is deallocated.  The caller is responsible for opening
   -- and connecting the given connection.


   PROCEDURE Allocate (Stream  : OUT Stream_Id;
                       Is_New  : OUT Boolean;
                       Network :     Transport_Defs.Network_Name;
                       Host    :     Transport_Defs.Host_Id;
                       Socket  :     Transport_Defs.Socket_Id);

   -- Find or create a stream to the given network/host/socket.
   -- Is_New is returned true iff a new connection had to be
   -- built: i.e. there was not already a stream in the pool.


   PROCEDURE Deallocate (Stream : Stream_Id);

   -- Return a stream to its pool.  It will not be
   -- disconnected immediately, but may be scavenged.


   PROCEDURE Disconnect (Stream : Stream_Id);

   -- Disconnect the transport connection.


   PROCEDURE Transmit (Into : Stream_Id; Data : Byte_Defs.Byte_String);
   PROCEDURE Receive  (From : Stream_Id; Data : OUT Byte_Defs.Byte_String);

   PROCEDURE Flush_Transmi_Buffer (Stream : Stream_Id);
   FUNCTION  Flush_Receive_Buffer
               (Stream : Stream_Id) RETURN Byte_Defs.Byte_String;

   -- If anything goes wrong with the above operations, the
   -- stream is disconnected, any associated buffers are
   -- deallocated, and the following exception is raised:

   Not_Connected : EXCEPTION;

   -- Each stream is unsynchronized, that is, if two tasks call
   -- TRANSMIT at the same time, or two tasks call RECEIVE at the
   -- same time, the stream state will get screwed up.  Don't.


   TYPE Pool_Id IS PRIVATE;

   FUNCTION Create (Network       : Transport_Defs.Network_Name;
                    Remote_Host   : Transport_Defs.Host_Id;
                    Remote_Socket : Transport_Defs.Socket_Id;
                    Local_Socket  : Transport_Defs.Socket_Id :=
                       Transport_Defs.Null_Socket_Id) RETURN Pool_Id;

   -- Create a pool of active streams.


   PROCEDURE Destroy (Pool : Pool_Id);

   -- Disconnect all streams in the pool,
   -- and terminate all associated tasks.


   PROCEDURE Allocate
                (Stream : OUT Stream_Id; Pool : Pool_Id; Is_New : OUT Boolean);

   -- Get an idle stream from the pool.  If no idle stream
   -- is available, create one, open and connect a
   -- transport connection, and return IS_NEW = TRUE.
   -- If this fails, raise NOT_CONNECTED.


   PROCEDURE Scavenge (Pool : Pool_Id);

   -- Disconnect any streams which have been deallocated
   -- for a while.


   PROCEDURE Scavenge;

   -- Scavenge all pools.
   -- This procedure is called periodically (every minute)
   -- by a scavenger task inside the service.


   PROCEDURE Finalize;

   -- Destroy all pools, and terminate all tasks.


   -- Like all pools with explicit allocate and deallocate
   -- operations, this service is vulnerable to clients
   -- which allocate a resource and then fail to deallocate
   -- it, e.g. because they terminate abnormally.  This
   -- problem isn't easily solved in standard Ada.  If your
   -- system has some way of dealing with it, you might
   -- consider extending this service to do the right thing.

PRIVATE

   TYPE Pool_Type (Network_Length       : Natural;
                   Remote_Host_Length   : Natural;
                   Remote_Socket_Length : Natural;
                   Local_Socket_Length  : Natural);

   TYPE Pool_List IS ACCESS Pool_Type;

   TYPE Pool_Id IS NEW Pool_List;

   TYPE Stream_Type;

   TYPE Stream_List IS ACCESS Stream_Type;

   TYPE Pool_Type (Network_Length       : Natural;
                   Remote_Host_Length   : Natural;
                   Remote_Socket_Length : Natural;
                   Local_Socket_Length  : Natural) IS
      RECORD
         Next          : Pool_List;
         Idle          : Stream_List;
         Network       : Transport_Defs.Network_Name (1 .. Network_Length);
         Remote_Host   : Transport_Defs.Host_Id (1 .. Remote_Host_Length);
         Remote_Socket : Transport_Defs.Socket_Id (1 .. Remote_Socket_Length);
         Local_Socket  : Transport_Defs.Socket_Id (1 .. Local_Socket_Length);
      END RECORD;



   SUBTYPE Unique_Id IS Integer;

   Null_Unique_Id : CONSTANT Unique_Id := Unique_Id'First;

   TYPE Stream_Id IS
      RECORD
         Stream : Stream_List;
         Unique : Unique_Id;
      END RECORD;

   Buffer_Size : CONSTANT := 2 ** 10;


   SUBTYPE Data_Count IS Natural RANGE 0 .. Buffer_Size;

   SUBTYPE Data_Index IS Data_Count RANGE 0 .. Data_Count'Last - 1;

   TYPE Buffer_Type IS
      RECORD
         First : Data_Index;
         Count : Data_Count;
         Data  : Byte_Defs.Byte_String (Data_Index'First .. Data_Index'Last);
      END RECORD;

   TYPE Stream_Type IS
      RECORD
         Next              : Stream_List := NULL;
         Pool              : Pool_Id     := NULL;
         Unique            : Unique_Id   := Null_Unique_Id;
         Referenced        : Boolean     := False;
         Connection        : Transport.Connection_Id;
         Transmit, Receive : Buffer_Type;
      END RECORD;


END Transport_Stream;

E3 Meta Data

    nblk1=a
    nid=0
    hdr6=14
        [0x00] rec0=1e rec1=00 rec2=01 rec3=056
        [0x01] rec0=1d rec1=00 rec2=02 rec3=034
        [0x02] rec0=00 rec1=00 rec2=0a rec3=002
        [0x03] rec0=1a rec1=00 rec2=03 rec3=04c
        [0x04] rec0=01 rec1=00 rec2=09 rec3=000
        [0x05] rec0=23 rec1=00 rec2=04 rec3=032
        [0x06] rec0=1c rec1=00 rec2=05 rec3=034
        [0x07] rec0=00 rec1=00 rec2=08 rec3=034
        [0x08] rec0=23 rec1=00 rec2=06 rec3=05a
        [0x09] rec0=08 rec1=00 rec2=07 rec3=000
    tail 0x2171d7fa8838e77eba2c6 0x489e0066482863c01