From: Gerd <GerdM.O@t-online.de>
Subject: Re: Tasking problem (delay)
Date: Sun, 19 Aug 2007 02:50:52 -0700
Date: 2007-08-19T02:50:52-07:00 [thread overview]
Message-ID: <1187517052.712238.207720@w3g2000hsg.googlegroups.com> (raw)
In-Reply-To: <1FHwi.64131$Fc.14346@attbi_s21>
On 15 Aug., 20:32, "Jeffrey R. Carter"
<spam.jrcarter....@acm.nospam.org> wrote:
>
> 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:
Thanks, you've pointed me into the right direction. I changed my code
such, that the delaytime is no longer a global variable (which in fact
was not good coding).
task worker is
entry Data(...);
entry set_delay_time(dt : Duration); -- inserted
end worker;
task body startup is
begin
...
-- WD_Delay := 1.0;
worker.set_delay_time (1.0);
...
end startup;
task body worker is
WD_Timeout : Duration := 1000.0;
begin
loop
select
accept Data (...);
or
accept set_selay_time (dt : Duration)
do
WD_Timeout := dt;
end;
or
delay WD_Timeout;
trigger_WD;
end select;
end loop;
end worker;
Would this be a good solution for my problem or are there any other
traps?
Gerd
next prev parent reply other threads:[~2007-08-19 9:50 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
2007-08-19 9:50 ` Gerd [this message]
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