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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,cd2c81bea5127375 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!postnews.google.com!i18g2000prf.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Starting a Task and Immediately Returning Date: Fri, 14 Nov 2008 05:41:42 -0800 (PST) Organization: http://groups.google.com Message-ID: <811556bd-60c9-43c0-927d-0e5d093dcfbd@i18g2000prf.googlegroups.com> References: <2ec689f1-8dc6-4cd8-b7f8-d0b7311317cc@h23g2000prf.googlegroups.com> NNTP-Posting-Host: 128.141.45.219 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1226670102 28777 127.0.0.1 (14 Nov 2008 13:41:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 14 Nov 2008 13:41:42 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i18g2000prf.googlegroups.com; posting-host=128.141.45.219; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2674 Date: 2008-11-14T05:41:42-08:00 List-Id: On 14 Lis, 14:26, Graham Stark wrote: > Can I do this using Ada's tasking facilities? Yes. > So far as I understand > them, all the Tasking examples I've looked at would have the return > executed only after Start_Long_Job has completed. Is that right? If the task is created locally then yes, this is what will happen - the enclosing scope (Web_Callback) will wait for the termination of its locally created task. > But, > obviously, you can't wait 10 minutes to reply to a web request. Then you need a task that will exist independently on Web_Callback. Make such a task (or even a whole bunch of them if that makes sense for this particular server) at the library level, which will give them independence on any scope. Add some facility for communicating to this task the description of what needs to be done (the "job") - for this you can use rendezvous or (better) job queue(s). In such a setup, your Web_Callback function can post the job to the queue without waiting for it being actually done, whereas the worker task can pick it from the queue and execute it in "background", while the final user enjoys the "your request has been accepted" page. -- Maciej Sobczak * www.msobczak.com * www.inspirel.com Database Access Library for Ada: www.inspirel.com/soci-ada