comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: How to determine if task is busy or not?
Date: Sat, 8 Aug 2009 03:56:11 -0700 (PDT)
Date: 2009-08-08T03:56:11-07:00	[thread overview]
Message-ID: <cee04170-811b-457d-acfa-5ca385c94319@d23g2000vbm.googlegroups.com> (raw)
In-Reply-To: 063cfc19-a8fa-41af-b948-d4f8540cb2ab@o36g2000vbl.googlegroups.com

Tomek Walkuski wrote:
> Is there any way to determine if task is busy or not?
>
> I have pool of worker tasks and I want to choose one of them to give
> some work to do.

I don't think you should see the problem in these terms.  You don't
have to select a task from the pool; the tasks select themselves as
they become available for a new job, e.g. each task would look like

loop
   Queue.Get_Next (Job);
   Process (Job);
end loop;

where Queue is a protected object and Get_Next removes a job from it
and passes it to the task. Of course, if there are no jobs in the
queue, it blocks until one arrives.

HTH

--
Ludovic Brenta.



  reply	other threads:[~2009-08-08 10:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-08 10:49 How to determine if task is busy or not? Tomek Walkuski
2009-08-08 10:56 ` Ludovic Brenta [this message]
2009-08-08 11:27   ` Dmitry A. Kazakov
2009-08-08 14:59     ` Maciej Sobczak
2009-08-08 16:00       ` Tomek Wałkuski
2009-08-08 18:22       ` Dmitry A. Kazakov
2009-08-08 18:39         ` Ludovic Brenta
replies disabled

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