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: a07f3367d7,8536537bd0d9744f X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Tail recursion upon task destruction 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: <1c0f7smxa240s.86mhal9qudx.dlg@40tude.net> Date: Wed, 18 Nov 2009 18:48:06 +0100 Message-ID: <1mj5dhshzuav0$.nccdkbhdtfn9$.dlg@40tude.net> NNTP-Posting-Date: 18 Nov 2009 18:48:03 CET NNTP-Posting-Host: d437e197.newsspool4.arcor-online.net X-Trace: DXC=d?V]8d3dnenj5k5aEF7ISm4IUK On Wed, 18 Nov 2009 11:31:59 +0100, stefan-lucks@see-the.signature wrote: > On Wed, 18 Nov 2009, Dmitry A. Kazakov wrote: > >> Now consider a case when the last screw is removed from the device. This >> is an operation eventually serviced by the device driver. I.e. within >> the device driver, you see, it was the last screw of the device and *if* >> there is no other references to the device, it must fall apart. This is >> a case where you wanted the device to commit suicide. There is nobody >> else out there to do this. The device is dangling. This is not the only >> use case, just one possible case. > > OK, so you have a task (a device) which notices that it is no longer > useful. You would like such a task to do some cleanup and to commit > "suicide". Unfortunately, it can't do the cleanup after the "suicide", > because it is "dead" then. And it can't cleanup itself before being > "dead" because it needs its local memory until the very moment of its > "death". > > But couldn't you just use (or maybe abuse) the features from > Ada.Task_Termination to do perform the cleanup, after the task has died? > Even if it the "death" is not by suicide (apart from > "suicide" = regular termination, the options are "murder" = abort and > "accident" = unhandled exception). > See . Yes, it is an interesting option. One could terminate the task and from the handler kill the object. The difficulty is that Ada.Task_Termination is not generic. It is not possible to pass a reference to the object to the handler. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de