From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b9c9ba98cff47596 X-Google-Attributes: gid103376,public From: dkristol@pollock.artists (David Kristola) Subject: Re: Message passing code Date: 1999/06/25 Message-ID: <7kva4m$nkb3@svlss.lmms.lmco.com>#1/1 X-Deja-AN: 493679673 Distribution: world References: Organization: Sun Microsystems, Inc. Reply-To: dkristol@pollock.artists Newsgroups: comp.lang.ada Date: 1999-06-25T00:00:00+00:00 List-Id: In article 123270@typhoon-sf.snfc21.pbi.net, tmoran@bix.com () writes: >>I can see this causing problems, especially when someone creates their >>Write routines to break up large objects into lots of small, discrete >>objects. The data would probably need to be wrapped at a lower level, >>and sent over as packets. This would cause some large objects to be >>sent as many small packets, and this could be terrible, depending on > I'm not clear on what you want, but if small packets from the many >small 'Writes worry you, buffer them up. For writing one or more records >as a single object to the clipboard, or writing it as a single >datagram write, I use a data marshalling package which includes: > -- Writes to a buffer will allocate additional memory from the > -- heap as needed. If you know reasonably accurately how much > -- you'll need, it will be more efficient to make the > -- Initial_Length big enough and thus avoid heap allocation. > -- > -- Any heap allocation will be freed automatically when a Buffer > -- ceases to exist. > > type Buffer_Type(Initial_Length : Ada.Streams.Stream_Element_Count) > is new Ada.Streams.Root_Stream_Type with private; > > procedure Write(Stream : in out Buffer_Type; > Item : in Ada.Streams.Stream_Element_Array); >etc. >Does that address (part of) the problem? Not really. How does the lower level know when the writing to the stream is done, and it should send the buffer? I guess there could be an explicit Flush command. But now i am doing all kinds of things that don't look like streams any more, so what is the point of trying to look like streams? I don't think streams are the right paradigm for this. When i have a message to send, i want to send the whole thing. That message will have many different things inside of it, and may be different lengths. I would also have to code a Write routine for each message type. That could get ugly. I would rather stick to the old technique of converting it to an array of bytes, and passing those into a Send routine. -- Completely bogus type for example. type Message_Type is record Message_ID : Base_Types.Unsigned_Integer_16_Type := Update_Contact_Table; Concat_ID : Contact_Types.Concat_ID_Type; Location : General_Types.Ownship_Relative_Position_Type; Condition : Something_Else.Some_Interesting_Type; Detection : Sonar.Detection_Method_Type; Checksum : Base_Types.Unsigned_Integer_16_Type; end record; Sonar_Update_Message : Message_Type; Sonar_Update_Message.Checksum := Message_Services.Calculate_Checksum(Convert(Sonar_Update_Message)); MPI.Send(Tactical_Channel, Convert(Sonar_Update_Message)); --djk, keeper of arcane lore & trivial fluff Home: David95037 at aol dot com Spam: goto.hades@welovespam.com