From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Task with access to itself?
Date: Wed, 05 Dec 2012 09:57:00 -0700
Date: 2012-12-05T09:57:00-07:00 [thread overview]
Message-ID: <k9nuct$f4n$1@dont-email.me> (raw)
In-Reply-To: <8738zk7gge.fsf@adaheads.sparre-andersen.dk>
On 12/05/2012 06:53 AM, Jacob Sparre Andersen wrote:
> I would like to maintain a collection of tasks, where the tasks
> themselves can register their availability.
>
> My immediate thought was to let the tasks know their own address
> ('Access), such that they can simply pass that to the collection of
> available tasks, when they are ready. But I haven't found a nice way to
> implement that pattern, so may be I should do it a different way.
We make extensive use of a similar pattern, but rather than having the tasks
register their availability and be given work to do, we have the tasks get their
work from a protected queue. The task body tends to look like
Forever : loop
exit Forever when Finalization.Control.Finalizing; -- Protected function
select
Work_Queue.Get (Item => Work_Item);
-- Blocks until something is on the queue
Process (Job_Info => Work_Item);
or
delay ...;
end select;
end loop Forever;
--
Jeff Carter
"If I could find a sheriff who so offends the citizens of Rock
Ridge that his very appearance would drive them out of town ...
but where would I find such a man? Why am I asking you?"
Blazing Saddles
37
next prev parent reply other threads:[~2012-12-05 16:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-05 13:53 Task with access to itself? Jacob Sparre Andersen
2012-12-05 14:18 ` Dmitry A. Kazakov
2012-12-05 16:57 ` Jeffrey Carter [this message]
2012-12-11 11:21 ` Jacob Sparre Andersen
2012-12-11 20:39 ` Jeffrey Carter
2012-12-12 20:25 ` Jacob Sparre Andersen
2012-12-12 21:11 ` Jeffrey Carter
2012-12-13 7:20 ` Jacob Sparre Andersen
2012-12-06 9:38 ` Egil Høvik
2012-12-06 19:53 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox