comp.lang.ada
 help / color / mirror / Atom feed
From: "Alejandro R. Mosteo" <alejandro@mosteo.com>
Subject: Re: Getting the index for an element in mutually referencing containers
Date: Mon, 13 Mar 2017 11:29:25 +0100
Date: 2017-03-13T11:29:25+01:00	[thread overview]
Message-ID: <oa5s4r$fdr$1@dont-email.me> (raw)
In-Reply-To: <lylgsac3bf.fsf@pushface.org>

On 12/03/17 09:22, Simon Wright wrote:
> Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
>
>> 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.
>>
> [...]
>>
>> 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.
>
> Thanks for the example!
>
> I still have a feeling that this is an in-computer software technique
> which resolves a software problem, rather than a necessary response to
> an application-domain problem.

This is how (most? I can only vouch for Java) garbage-collecting 
languages work. Thus is a common way of thinking for many programmers (I 
would say most think first of ref-counted ptrs before weak refs when 
faced with the problem being discussed, but that's just my impression). 
And the source of a kind of memory leak, which is the problem you get in 
exchange for no dangling pointers...

Not surprisingly, C++ has standardized the whole shebang, with both 
semantics being discussed here covered:

http://en.cppreference.com/w/cpp/memory

Alex.

  parent reply	other threads:[~2017-03-13 10:29 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-09 13:45 Getting the index for an element in mutually referencing containers Mart van de Wege
2017-03-09 15:25 ` Egil H H
2017-03-09 15:45   ` Mart van de Wege
2017-03-09 16:02     ` Mart van de Wege
2017-03-09 16:11     ` Egil H H
     [not found] ` <ly7f3xedp4.fsf@pushface.org>
     [not found]   ` <86k27xpikd.fsf@gaheris.avalon.lan>
     [not found]     ` <lywpbxc9my.fsf@pushface.org>
     [not found]       ` <86wpbxneuz.fsf@gaheris.avalon.lan>
     [not found]         ` <o9vcbp$t0t$1@franka.jacob-sparre.dk>
2017-03-11  6:45           ` Mart van de Wege
2017-03-11  8:40           ` Simon Wright
2017-03-11  8:58             ` Dmitry A. Kazakov
2017-03-11 11:21               ` Simon Wright
2017-03-11 14:18                 ` Dmitry A. Kazakov
2017-03-11 20:05                   ` Simon Wright
2017-03-11 20:52                     ` Dmitry A. Kazakov
2017-03-11 21:46                       ` Simon Wright
2017-03-11 22:37                         ` Niklas Holsti
2017-03-12  8:22                           ` Simon Wright
2017-03-12  9:38                             ` G.B.
2017-03-12 11:21                               ` Simon Wright
2017-03-13 10:29                             ` Alejandro R. Mosteo [this message]
2017-03-12  8:20                         ` Dmitry A. Kazakov
2017-03-12 11:30                           ` Simon Wright
2017-03-12 11:55                             ` Dmitry A. Kazakov
2017-03-12 16:44                               ` Simon Wright
2017-03-12 17:42                                 ` Dmitry A. Kazakov
2017-03-13 19:55                                   ` Randy Brukardt
2017-03-13 20:53                                     ` Dmitry A. Kazakov
2017-03-14 20:40                                       ` Randy Brukardt
2017-03-15  8:44                                         ` Dmitry A. Kazakov
2017-03-15 20:12                                           ` Randy Brukardt
2017-03-16  2:59                                             ` Paul Rubin
2017-03-16  9:04                                             ` Dmitry A. Kazakov
2017-03-13 23:25                                   ` Simon Wright
2017-03-14  8:25                                     ` Dmitry A. Kazakov
2017-03-12  1:36             ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox