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,1d4203bfa2644439 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.84.202 with SMTP id b10mr3820837paz.43.1354726623279; Wed, 05 Dec 2012 08:57:03 -0800 (PST) Path: s9ni29229pbb.0!nntp.google.com!news.glorb.com!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Task with access to itself? Date: Wed, 05 Dec 2012 09:57:00 -0700 Organization: Also freenews.netfront.net; news.tornevall.net Message-ID: References: <8738zk7gge.fsf@adaheads.sparre-andersen.dk> Mime-Version: 1.0 Injection-Date: Wed, 5 Dec 2012 16:57:02 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="21c3f140f3af3f178681f105ae93b5ae"; logging-data="15511"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GB88W8PpTm468xTmsIQoIOJMLHpXI4Uk=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <8738zk7gge.fsf@adaheads.sparre-andersen.dk> Cancel-Lock: sha1:/Y5RuMGcchspTaju8uEFAYjK9o4= Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-12-05T09:57:00-07:00 List-Id: 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