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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!1.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Getting the index for an element in mutually referencing containers Date: Sun, 12 Mar 2017 00:37:01 +0200 Organization: Tidorum Ltd Message-ID: References: <86o9xa36oq.fsf@gaheris.avalon.lan> <86k27xpikd.fsf@gaheris.avalon.lan> <86wpbxneuz.fsf@gaheris.avalon.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net KXriKl4dcyJ5Zq/PcmZdxgejfax0wwZEocUaOqiHL7LY4GdN3c Cancel-Lock: sha1:sho6HRMq4cZmUOZiPY7tE7T75+8= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:27843 Date: 2017-03-12T00:37:01+02:00 List-Id: On 17-03-11 23:46 , Simon Wright wrote: > Basically, I (Simon, now) am having trouble thinking of an application > where reference counting would be an appropriate solution. How about this one: the SW generates messages (telemetry packets) reporting various sorts of data and events. Depending on the kind of the message, the same message may have to be distributed within the SW to several destinations: a radio link, a log file (mass memory), a message-monitoring service (for possible autonomous action), etc. Each destination has a queue of incoming messages, and the queueing and processing time for a given message varies accordingly. Rather than copy the (possibly long) message into each destination's queue, the queues hold references to a single, shared instance of the message, dynamically allocated in a memory pool. These references are counted. When, finally, all destinations have processed the message, the message's reference count reaches zero, and the message can be deallocated. This use of reference counting is a typical design in satellite on-board SW. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .