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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.46.1.38 with SMTP id 38mr1764179ljb.3.1466647947944; Wed, 22 Jun 2016 19:12:27 -0700 (PDT) X-Received: by 10.157.60.49 with SMTP id q46mr419235otc.0.1466647947852; Wed, 22 Jun 2016 19:12:27 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!goblin1!goblin.stu.neva.ru!oe3no9156178lbb.1!news-out.google.com!f5ni11856lbb.0!nntp.google.com!w10no7356945lbo.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 22 Jun 2016 19:12:27 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=216.121.226.25; posting-account=ENgozAkAAACH-stq5yXctoDQeZQP2E6J NNTP-Posting-Host: 216.121.226.25 References: <66c14298-c62d-4f4b-b0c0-e969454f9334@googlegroups.com> <2e39857a-7121-476b-807a-d2bff1e598f4@googlegroups.com> <431af616-7df3-4e4d-9262-26ed68cb74c7@googlegroups.com> <037df2b8-b9c4-4447-87ee-cc89d7072b30@googlegroups.com> <15914c54-191c-4f37-b754-282855d1aeaf@googlegroups.com> <3e25c9a0-469c-4487-b78e-6f87434f87fa@googlegroups.com> <2e69ca6f-484c-4d58-b0fe-d17a744b1418@googlegroups.com> <9ada1cdc-2fbd-4009-99f1-aba71ac1b9d2@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2954ae98-c4a0-4089-93bc-97854e009785@googlegroups.com> Subject: Re: Generic Embedded List Nodes From: Warren Injection-Date: Thu, 23 Jun 2016 02:12:27 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:30885 Date: 2016-06-22T19:12:27-07:00 List-Id: On Tuesday, 21 June 2016 17:38:36 UTC-4, Niklas Holsti wrote: ... > type Emb_Node_T is tagged; >=20 > type Emb_Node_Ref_T is access all Emb_Node_T'Class; >=20 > type Emb_Node_T is tagged record > Prev, Next : Emb_Node_Ref_T; > -- Prev and Next are null if the node is not in any list. > -- When the node is first in a list, Prev points to the list head. > -- When the node is last in a list, Next is null. > end record; >=20 > subtype List_T is Emb_Node_T; > -- A list head. > -- Next points to the first node in the list. > -- Prev is null. ... The insertion, traversal and deletes are generally no problem. The problem = occurs when traversing to access the object. Let's say you have a list of t= imed out sockets (in pseudo code): node :=3D head.next; while node /=3D null loop next_node :=3D node.next; -- now access the object holding "node" so that it can be freed node.unlink; Free(node's object); node :=3D node_next; end loop;=20 I keep bumping back into this Ada compiler restriction, which is maddening.= It doesn't seem easily fooled. I think the only simple way to do this in Ada, is to allocate a very large = array of=20 Access to record values, for each socket (I know what the max # of sockets = are). The descriptors start at zero so this works well. The list link nodes can easily save and allow me to retrieve the POSIX sock= et (fd) number without any compiler restrictions. So when I traverse to a g= iven node, I can pull the fd out of the link node, and know that I have soc= ket 90345, for example. Then I can index to the socket's event record acces= s value in the array. Normally, I already know the fd in the event handler epoll/kqueue, but the = lists get traversed for timeouts and deferred closes. So given a timeout no= de for example, I need to be able to get the object that belongs to it so I= can do things like free it etc. Warren