* help on task types
@ 1999-03-03 0:00 coxaw
1999-03-03 0:00 ` Stephen Leake
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: coxaw @ 1999-03-03 0:00 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help on task types
1999-03-03 0:00 help on task types coxaw
@ 1999-03-03 0:00 ` Stephen Leake
1999-03-03 0:00 ` dennison
1999-03-03 0:00 ` Steve Folly
2 siblings, 0 replies; 4+ messages in thread
From: Stephen Leake @ 1999-03-03 0:00 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help on task types
1999-03-03 0:00 help on task types coxaw
1999-03-03 0:00 ` Stephen Leake
@ 1999-03-03 0:00 ` dennison
1999-03-03 0:00 ` Steve Folly
2 siblings, 0 replies; 4+ messages in thread
From: dennison @ 1999-03-03 0:00 UTC (permalink / raw)
In article <36DD8EBF.EAA@rmcs.cranfield.ac.uk>,
coxaw@rmcs.cranfield.ac.uk wrote:
> 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 ?
Hmmm. This sounds suspiciously like a homework problem.
I know of 3 ways to pass task specific info to such a task.
o Make the object a discriminant in the task type declaration.
o Pass the object to the task via a rendezvous.
o Use a generic package w/ a task instead of a task type, and instantiate
w/ the object.
There are probably more.
T.E.D.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help on task types
1999-03-03 0:00 help on task types coxaw
1999-03-03 0:00 ` Stephen Leake
1999-03-03 0:00 ` dennison
@ 1999-03-03 0:00 ` Steve Folly
2 siblings, 0 replies; 4+ messages in thread
From: Steve Folly @ 1999-03-03 0:00 UTC (permalink / raw)
coxaw wrote in message <36DD8EBF.EAA@rmcs.cranfield.ac.uk>...
>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 ?
>
1. Why not create an entry point with a parameter specifying the file?
2. Or make it a discriminated task type, where the discriminant is an access
string type which identifies the file - that way you don't need to
explicitly call an entry point; just declaring it would start the task and
it could read the discriminant.
Steve Folly
mailto:steve@follysplace.demon.co.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-03-03 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-03 0:00 help on task types coxaw
1999-03-03 0:00 ` Stephen Leake
1999-03-03 0:00 ` dennison
1999-03-03 0:00 ` Steve Folly
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox