From: "Jeffrey R. Carter" <spam.jrcarter.not@acm.nospam.org>
Subject: Re: Tasking problem (delay)
Date: Wed, 15 Aug 2007 18:32:33 GMT
Date: 2007-08-15T18:32:33+00:00 [thread overview]
Message-ID: <1FHwi.64131$Fc.14346@attbi_s21> (raw)
In-Reply-To: <1187197490.377548.41000@b79g2000hse.googlegroups.com>
Gerd wrote:
>
> WD_Delay: Duaration := 1000.0; -- so do not trigger on start
Assuming this is "Duration" ...
> task body startup is
> begin
> ...
> WD_Delay := 1.0;
> ...
> end startup;
>
> task body worker is
> begin
> loop
> select
> accept Data (...)
> or
> delay WD_Timeout;
... and this is "WD_Delay"
> trigger_WD;
> end select;
> end loop;
> end worker;
The expression in the delay statement (in this case "WD_Delay") is
evaluated once upon reaching the select statement. So this will wait for
a call to Data, or for the value of WD_Delay at the time the select
statement was reached, whichever comes 1st.
Using unprotected shared variables is not a good idea anyway. I'd
suggest something more like:
task Worker is
entry Startup_Complete;
entry Data (...);
end Worker;
task body Worker is
WD_Delay : constant := 1.0;
begin -- Worker
select
accept Startup_Complete;
or
terminate;
end select;
Forever : loop
select
accept Data ...
or
delay WD_Delay;
Trigger_WD;
end select;
end loop Forever;
end Worker;
If Worker needs to be able to accept data before startup is complete,
this would become
task body Worker is
WD_Delay : Duration := 1_000.0;
begin -- Worker
Forever : loop
select
accept Data ...
or
accept Startup_Complete;
WD_Delay := 1.0;
or
delay WD_Delay;
Trigger_WD;
end select;
end loop Forever;
end Worker;
--
Jeff Carter
"Clear? Why, a 4-yr-old child could understand this
report. Run out and find me a 4-yr-old child. I can't
make head or tail out of it."
Duck Soup
94
next prev parent reply other threads:[~2007-08-15 18:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-15 17:04 Tasking problem (delay) Gerd
2007-08-15 17:34 ` Georg Bauhaus
2007-08-15 18:32 ` Jeffrey R. Carter [this message]
2007-08-19 9:50 ` Gerd
2007-08-19 18:26 ` Jeffrey R. Carter
2007-08-16 5:16 ` anon
2007-08-16 5:17 ` AW: " Grein, Christoph (Fa. ESG)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox