From: Simon Wright <simon@pushface.org>
Subject: Re: tasks as part of record
Date: Mon, 06 Oct 2014 09:24:01 +0100
Date: 2014-10-06T09:24:01+01:00 [thread overview]
Message-ID: <lyiojxbo7y.fsf@pushface.org> (raw)
In-Reply-To: c474fef2-701c-4968-94eb-aec57bee0dd3@googlegroups.com
Stribor40 <ikamzic@gmail.com> writes:
> I though it would be easier if task is componenet of record. What i
> would like is that every time task runs i would like to operate on
> components of student record.
> For example for each student there will be one tasks. When each tasks
> run i want it to identify yourself to the screen with student number
> value. For example
>
> This is task #. -- where # is student number
I'm not saying this is a good idea; limited types can be awkward, and
there will be all sorts of problems with the tasking if you ever want to
delete a student. But, for the record,
with Ada.Text_IO; use Ada.Text_IO;
procedure Strib is
type Student;
task type T (This : access Student) is
entry Start (Number : Positive);
end T;
type Student is limited record -- has to be limited
Student_Number : Positive range 1 .. 10;
Name : String (1 .. 10);
Count : Integer;
The_Task : T (Student'Access); -- the current Student
end record;
task body T is
begin
accept Start (Number : Positive) do
Put_Line ("starting task" & Positive'Image (Number));
This.Student_Number := Number;
end Start;
delay 1.0;
Put_Line ("this is task" & Positive'Image (This.Student_Number));
end T;
Students : array (1 .. 10) of Student;
begin
for J in Students'Range loop
Students (J).The_Task.Start (Number => J);
end loop;
end Strib;
next prev parent reply other threads:[~2014-10-06 8:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-04 13:11 tasks as part of record Stribor40
2014-10-04 13:33 ` Simon Wright
2014-10-04 22:12 ` Stribor40
2014-10-05 7:36 ` Jacob Sparre Andersen
2014-10-05 8:11 ` Niklas Holsti
2014-10-06 3:47 ` Stribor40
2014-10-06 5:43 ` Jeffrey Carter
2014-10-06 7:18 ` Niklas Holsti
2014-10-06 8:00 ` Dmitry A. Kazakov
2014-10-06 11:40 ` G.B.
2014-10-06 8:06 ` Simon Wright
2014-10-06 8:24 ` Simon Wright [this message]
2014-10-12 22:33 ` compguy45
2014-10-13 7:32 ` Simon Wright
2014-10-13 14:45 ` compguy45
2014-10-13 15:33 ` Shark8
2014-10-18 18:21 ` Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox