From: compguy45@gmail.com
Subject: Re: tasks as part of record
Date: Sun, 12 Oct 2014 15:33:57 -0700 (PDT)
Date: 2014-10-12T15:33:57-07:00 [thread overview]
Message-ID: <313c39ae-dd7b-4993-910a-0f28dfc35b65@googlegroups.com> (raw)
In-Reply-To: <lyiojxbo7y.fsf@pushface.org>
On Monday, October 6, 2014 4:24:02 AM UTC-4, Simon Wright wrote:
>
>
>
> > 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;
Doesnt this code above give warning "warning: variable "Students" is read but never assigned"??
next prev parent reply other threads:[~2014-10-12 22:33 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
2014-10-12 22:33 ` compguy45 [this message]
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