comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: tasks as part of record
Date: Sat, 04 Oct 2014 14:33:01 +0100
Date: 2014-10-04T14:33:01+01:00	[thread overview]
Message-ID: <ly61g09cz6.fsf@pushface.org> (raw)
In-Reply-To: 294a973f-5222-4aa3-8971-777cd2eb9174@googlegroups.com

Stribor40 <ikamzic@gmail.com> writes:

> http://www.infres.enst.fr/~pautet/Ada95/chap29.htm
>
> Unfortunately this tutorial doesnt show anything....can someone show
> me how to create few records where each record contain task
> please. Say if I want record Student...
>
>   type Student is record
>        Student_Number  : Positive range 1 .. N;
>        Name : String(1..20);
>        Count    : Integer ;
>        --??tasks
>    end record;
>
> and how to create 10 students records....

   with Ada.Text_IO; use Ada.Text_IO;
   procedure Strib is
      task type T is
         entry Start (Name : String);
      end T;
      type Student is record
         Student_Number : Positive range 1 .. 10;
         Name : String (1 .. 10);
         Count : Integer;
         The_Task : T;
      end record;
      task body T is
      begin
         accept Start (Name : String) do
            Put_Line ("started " & Name);
         end Start;
      end T;
      Students : array (1 .. 10) of Student;
   begin
      for J in Students'Range loop
         Students (J).Student_Number := J;  -- etc
         Students (J).The_Task.Start ("student" & Integer'Image (J));
      end loop;
   end Strib;

Each The_Task may need access to the Student record of which it's a
component. If so, ask again.


  reply	other threads:[~2014-10-04 13: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 [this message]
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
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