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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,be3d89c2ad66a506 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!atl-c08.usenetserver.com!news.usenetserver.com!pc02.usenetserver.com!ALLTEL.NET-a2kHrUvQQWlmc!not-for-mail Date: Fri, 04 Nov 2005 11:15:18 -0600 From: "Marc A. Criley" User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Advice on abort References: <1131117934.372137.244900@g44g2000cwa.googlegroups.com> In-Reply-To: <1131117934.372137.244900@g44g2000cwa.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@usenetserver.com Organization: UseNetServer.com X-Trace: d123b436b9735a13cf28417347 Xref: g2news1.google.com comp.lang.ada:6203 Date: 2005-11-04T11:15:18-06:00 List-Id: REH wrote: > What are the best options when a task needs to be terminated, but > signaling the task may not be possible? We have tasks that sometimes > need to be terminated, but may potentially be blocked on a resource, > such as a socket. Currently we use OS-specific calls to terminate the > task, but I've never liked that. I've been thinking of using the abort > statement, but I don't think that's very graceful either. I also would > rather not complicate the code (or force polling behavior) by making > the sockets non-blocking. Any advice? For the _specific_ case of blocking on a socket... IF you're using GNAT, and IF you're using GNAT.Sockets, then take a look at the Selector functionality. (This is an abstraction over the C select() function.) Basically, once you get your socket and set up your selector you wait for traffic with a Check_Selector(...) call. When you're ready to shut down, you can call Abort_Selector(...). CheckSelector() then returns with a status of Aborted, and you can then go on about your termination. I changed over to this in the version of DTraq that's getting updated and the code is now _much_ cleaner in this area. (I don't know when Check_Selector and Abort_Selector were added to GNAT.Sockets, coulda been years ago. I just happened to stumble across them when scanning through the spec a few months ago :-) -- Marc A. Criley -- McKae Technologies -- www.mckae.com -- DTraq - XPath In Ada - XML EZ Out