comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada tasking question
Date: Thu, 19 Apr 2007 09:49:14 +0200
Date: 2007-04-19T09:49:14+02:00	[thread overview]
Message-ID: <hw26w6x2kfky.1bbk2kgdq4yci$.dlg@40tude.net> (raw)
In-Reply-To: 20070418201307.18a85fd9@cube.tz.axivion.com

It makes no sense to finish a task after a bucket was processed. I would
propose an alternative design, where a task would ask the buckets
collection for a job to do. It would then process the bucket and ask for a
next one. When the collection responds: no more buckets, the task finishes:

type Bucket is new Ada.Finalization.[Limited_]Controlled ...
procedure Process (Job : in out Bucket);

type Bucket_List is record
   Buckets : Bucket_Array (...);
   Indexer : a protected object to index buckets concurrently
end record;

procedure Do_One (List : in out Bucket_List) is
begin
   Process (List.Buckets (List.Indexer.Get_Next));
      -- Get_Next raises exception No_Buckets,
      -- when the end of List.Buckets is reached
end Do_One;

task body Bucket_Worker is
begin
   loop
      Do_One (List);
   end loop;
exception
   when No_Buckets =>
      null;
end Bucket_Worker;

You start as many Bucket_Workers as you find appropriate.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2007-04-19  7:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-18 18:13 Ada tasking question Stefan Bellon
2007-04-18 18:40 ` Randy Brukardt
2007-04-18 20:12   ` Jeffrey R. Carter
2007-04-18 22:43     ` Stefan Bellon
2007-04-19  2:02       ` Steve
2007-04-18 21:08   ` Leif Holmgren
2007-04-18 22:57     ` Stefan Bellon
2007-04-18 23:41       ` Brian May
2007-04-19  0:25       ` Randy Brukardt
2007-04-19  8:02         ` Stefan Bellon
2007-04-19 12:47         ` Jacob Sparre Andersen
2007-04-19 16:11           ` Anh Vo
2007-04-20  4:32           ` Jeffrey R. Carter
2007-04-19  0:50       ` Jeffrey R. Carter
2007-04-18 19:50 ` Alex R. Mosteo
2007-04-18 23:00   ` Stefan Bellon
2007-04-19 20:37   ` Pascal Obry
2007-04-19  2:13 ` jimmaureenrogers
2007-04-19  7:49 ` Dmitry A. Kazakov [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-10-18  0:00 whiting_ms@corning.com (Matt Whiting)
replies disabled

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