comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Starting a Task and Immediately Returning
Date: Fri, 14 Nov 2008 05:41:42 -0800 (PST)
Date: 2008-11-14T05:41:42-08:00	[thread overview]
Message-ID: <811556bd-60c9-43c0-927d-0e5d093dcfbd@i18g2000prf.googlegroups.com> (raw)
In-Reply-To: 2ec689f1-8dc6-4cd8-b7f8-d0b7311317cc@h23g2000prf.googlegroups.com

On 14 Lis, 14:26, Graham Stark <graham.st...@virtual-worlds.biz>
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



  reply	other threads:[~2008-11-14 13:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-14 13:26 Starting a Task and Immediately Returning Graham Stark
2008-11-14 13:41 ` Maciej Sobczak [this message]
2008-11-14 15:13   ` Jean-Pierre Rosen
2008-11-15 12:04     ` Samuel Tardieu
2008-11-15 15:53       ` sjw
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox