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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,308a261188818cce X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!bolzen.all.de!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Pointers explained? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1185817996.143086.317990@g12g2000prg.googlegroups.com> Date: Mon, 30 Jul 2007 22:11:10 +0200 Message-ID: <1u6yxxpe3777x.qmvqq9xczlwy.dlg@40tude.net> NNTP-Posting-Date: 30 Jul 2007 22:10:52 CEST NNTP-Posting-Host: b1d32b76.newsspool1.arcor-online.net X-Trace: DXC=@2NS@5hiaW3RadXUBHgFh3ic==]BZ:af>4Fo<]lROoR1Fl8W>\BH3Y2@d>KKY5RmS6DNcfSJ;bb[5IRnRBaCdA\L?adL_lc;ilT7R0V57m8 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:1277 Date: 2007-07-30T22:10:52+02:00 List-Id: On Mon, 30 Jul 2007 10:53:16 -0700, shaunpatterson@gmail.com wrote: > Now from my factory create method, I'm returning a Message_Class. > This message_class is stored in another record to be handled again later: > > type CallbackEvent is > record > msg : Message_Class; > ... > end record; Are you sure that you want to copy messages? Let there are 10000 subscribers to a messages publisher. Then upon emitting a message you will copy it 10000 times! I would consider: type CallbackEvent (Message : access Message'Class) is > Now my basic problem -- or not really a problem -- is that to create > the Message_Class I have to use "new" and allocate and deallocate memory. > Now - my solution was to re-write my message factory to return a type > Message'Class. However, I went > to change my callback structure to: No problem, leave factory as-is, returning Message'Class. Whenever you would need to allocate Message, you could still do it like this: new Message'Class'(Factory (...)); Factory returns Message'Class used to initialize the memory allocated for the new object. > type CallbackEvent is > record You could consider making reference counted Messages and handles to them. Handles will be copied around and placed into containers like CallbackEvent. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de