comp.lang.ada
 help / color / mirror / Atom feed
* Newbie: Task parametering
@ 2005-10-17  0:23 Andrew Price
  2005-10-17  0:53 ` jimmaureenrogers
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Price @ 2005-10-17  0:23 UTC (permalink / raw)


Hello all,

I need to initialise some tasks with a few parameters when I instantiate 
them. After looking at
http://www.adaic.com/docs/95style/html/sec_6/6-1-3.html it seems the 
best way to do this is using an access type discriminant to pass a 
record to the tasks.

With that in mind, I created this record type;

type Task_Data is
       record
       Name : aliased String(1..8);
       Period : aliased Duration;
       Repetitions : aliased Integer;
    end record;


and then in the main part of my program I use it like this;

    type Task_Handle is access A_Task;  -- used to point to the task
    Another_Task : Task_Handle;
    type Data_Handle is access Task_Data; -- used to point to its data
    Data_For_Task : Data_Handle;

begin  -- The main prog will now spawn three of the above tasks

    -- Parameterise the first task and then start it.
    Data_For_Task := new Task_Data;
    Data_For_Task.Name := "Task A  ";
    Data_For_Task.Period := 0.5;
    Data_For_Task.Repetitions := 5;
    Another_Task := new A_Task(Data_For_Task);

So while this approach works, I can't help but feel that I'm going about 
this in a 'long winded' way (especially coming from a mostly C background).

Is there are neater way of putting the data into the Task_Data records? 
Or is there an better approach to the whole task parameterisation I 
should consider?

Now is probably a good time to add the disclaimer that this is part of a 
lab work exercise for a course I'm currently undertaking at university.

Thanks in advance for any advice,
Andrew.



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-10-17 22:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-17  0:23 Newbie: Task parametering Andrew Price
2005-10-17  0:53 ` jimmaureenrogers
2005-10-17  2:37   ` tmoran
2005-10-17  4:10     ` tmoran
2005-10-17  4:58   ` Andrew Price
2005-10-17 10:02     ` Jacob Sparre Andersen
2005-10-17 15:57   ` Poul-Erik Andreasen
2005-10-17 22:51   ` Stephen Leake

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