comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: help on task types
Date: 1999/03/03
Date: 1999-03-03T00:00:00+00:00	[thread overview]
Message-ID: <u678i8bv8.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 36DD8EBF.EAA@rmcs.cranfield.ac.uk

coxaw <coxaw@rmcs.cranfield.ac.uk> writes:

> If I declare a task type that reads input from a file and prints to
> screen
> 
> Then instantiate 3 copies of this type
> 
> can i tell each one to read from a different file ?
> 
> and how is it done ?
> 
> ie
> 
> task type reader_type is
> blah
> blah
> blah
> end reader;
> 
> read1:reader_type;
> read2:reader_type;
> 
> but read1 is to read from inFile1
> and read2 from inFile2

One way is to use a discriminant:

task type reader_type (File_Name : access String) is
...
end reader_type;

File_Name_1 : aliased constant String := "inFile1";
read1 : reader_type (File_Name_1'access);

Discriminants must be scalars, so you can't put a string there directly.

Another way is to pass the file name to the task via an Initialize
entry:

task type reader_type is
    entry Initialize (File_Name : in String);
end reader_type;

This requires the user to call Initialize, which is usually a pain. But
you can pass more complex stuff that way, than with a discriminant.

-- Stephe




      parent reply	other threads:[~1999-03-03  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-03  0:00 help on task types coxaw
1999-03-03  0:00 ` Steve Folly
1999-03-03  0:00 ` dennison
1999-03-03  0:00 ` Stephen Leake [this message]
replies disabled

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