RE: Timing events in GNAT GPL 2006
- From: "Vo, Anh \(US SSA\)" <anh.vo@xxxxxxxxxxxxxx>
- Date: Fri, 12 Jan 2007 09:40:19 -0800
--
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Real_Time.Timing_Events; use Ada.Real_Time.Timing_Events;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Timing_Event is
protected Clock_Tick is
procedure Inc_Clock (Ev : Timing_Event);
end Clock_Tick;
Tick : Timing_Event;
One_Sec : constant Time_Span := Seconds (1);
protected body Clock_Tick is
procedure Inc_Clock (Ev : Timing_Event)
is
begin
Put_Line ("Inc_Sec");
-- using Time_Span
Set_Handler (Tick, One_Sec, Handler => Inc_Clock'Access);
end Inc_Clock;
end Clock_Tick;
begin
-- using absolute time
Set_Handler (Tick, Clock + One_Sec, Clock_Tick.Inc_Clock'Access);
loop null; end loop;
end Test_Timing_Event;
-- >>
There are three things wrong with your codes. Two of them are critical.
1. The protected procedure Inc_Clock has wrong parameter mode. It must
be in out mode.
2. The call Set_Handler from the protected procedure will result in a
deadlock it is run.
3. Protected object must be declared at the library level. Yours is not.
As the result, non-local pointer cannot point to local object error at
lines 20 and 26
I designed for both one shot and periodic timers using Timing Event. If
it is helpful, I will post my code here. Just let me know.
AV
.
- References:
- Timing events in GNAT GPL 2006
- From: Rolf
- Timing events in GNAT GPL 2006
- Prev by Date: Timing events in GNAT GPL 2006
- Next by Date: Re: Cannot initialize entities of limited type?
- Previous by thread: Timing events in GNAT GPL 2006
- Next by thread: Re: RE: Timing events in GNAT GPL 2006
- Index(es):
Relevant Pages
|