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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,589fabad165a40d9,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.180.106.199 with SMTP id gw7mr288401wib.0.1348129046149; Thu, 20 Sep 2012 01:17:26 -0700 (PDT) Path: q11ni1725wiw.1!nntp.google.com!fu-berlin.de!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Date: Thu, 20 Sep 2012 10:17:22 +0200 From: =?ISO-8859-1?Q?Thomas_L=F8cke?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120909 Thunderbird/15.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Tasking and timing out Message-ID: <505ad112$0$295$14726298@news.sunsite.dk> Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 77.234.168.90 X-Trace: news.sunsite.dk DXC=B8NPOe3faegD]J=fIXJe6oYSB=nbEKnkk6\_IN@R6KLh3ZOKe3?:>XacAE?;m5ccYc3>^Oo7SF Hey all, I need to be able to be abandon a socket connection in a task and let the task complete if: a. the socket connect takes too long to complete or b. the Start task entry isn't called within a set timeframe My current solution appears to do the trick just fine, but I'm not sure if it's a "good" solution, specifically the nested select block pains me to no end - I can't explain why though. :) Here's what I've got: https://gist.github.com/3754529 Or without the fancy syntax highlighting from GitHub: task body AMI_Action is begin select accept Start do select delay 2.0; raise AMI_Action_Error with Connect_Timed_Out_Message; then abort AWS.Net.Std.Connect (Socket => Action_Socket, Host => Config.Get (PBX_Host), Port => Config.Get (PBX_Port)); end select; end Start; or delay 3.0; raise AMI_Action_Error with No_Call_On_Start_Received; end select; loop -- Mad socket action! end loop; exception -- Catch exceptions, log issue and complete. end AMI_Action; The general idea is that if the call to AWS.Net.Std.Connect takes more than 2 seconds to complete, then I raise an exception or if the Start entry isn't called before 3 seconds have passed, then I also raise an exception. In both cases I just want the task to log the issue and complete. It works - at least I haven't been able to make it fail in my tests, it's just that I'm not sure if this is the right way to live up to the requirements - maybe there's a better way? Advice and/or suggestions are more than welcome. -- Thomas L�cke | thomas@12boo.net | http://12boo.net