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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c4003439e5ce36e1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!news-mue1.dfn.de!news-fra1.dfn.de!news.tele.dk!not-for-mail Sender: malo@0x535ba1f6.boanxx18.adsl-dhcp.tele.dk Newsgroups: comp.lang.ada Subject: Re: Converting access values References: From: Mark Lorenzen Date: 06 Jan 2005 01:28:42 +0100 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: TDC Totalloesninger NNTP-Posting-Host: 83.91.161.246 X-Trace: 1104971322 dtext02.news.tele.dk 182 83.91.161.246:52188 X-Complaints-To: abuse@post.tele.dk Xref: g2news1.google.com comp.lang.ada:7502 Date: 2005-01-06T01:28:42+01:00 List-Id: Jeffrey Carter writes: > Mark Lorenzen wrote: > > > Hello, > > Imagine that we have a program that reads large amount of data from > > (for example) a network connection into buffers. The data is just to > > be seen as a sequence of octets. > > We now want to copy parts ("slices") of the data to other tasks that > > may do something interesting with these slices. The rate of data is > > too high to simply copy the wanted slices, so instead we make "cheap > > copies". > > The idea is that these cheap copies simply point to slices within the > > large buffer and this way all copies refer to a common buffer and no > > real copying is going on. > > The answer, as is often the case with Ada, is that you don't need to > use access types to do what you want. Assuming you have a big > Storage_Array and want to pass a slice of it somewhere, just pass the > slice: > > Buf : Stream_Element_Array (Really_Big); > ... > procedure Do_Something (Data : in [out] Stream_Element_Array); > ... > Do_Something (Data => Buf (Low .. High) ); > > I don't know of any compiler that will pass Data by copy; if yours > does, you should seriously consider changing compilers. What will be > passed is a slice descriptor, which may be bigger than an access value > but will still be very small. Actual access to the buffer will be by > reference. My problem is not passing a slice as an actual parameter to a subprogram. I have a task which receives Buf, slices it up and then passes the slices to other tasks using queues implemented as protected types. When passing the slice to a queue, it will probably not be done by copy, but the queue puts the slice into a data structure (list, array etc.) and there we definately have a real assignment and copy. > > -- > Jeff Carter > "It's all right, Taggart. Just a man and a horse being hung out there." > Blazing Saddles > 34 - Mark Lorenzen