From: Bender <Jeffrey.S.Morrison@gmail.com>
Subject: Running a background task
Date: Thu, 15 May 2008 13:51:58 -0700 (PDT)
Date: 2008-05-15T13:51:58-07:00 [thread overview]
Message-ID: <f47b5be0-7488-439e-903a-d16cbd4116f2@z24g2000prf.googlegroups.com> (raw)
Hi, I'm pretty new to Ada, and need to figure out a way to kick off a
background task that runs more or less forever, while normal execution
of the program continues.
Thus far I've figured out how to create a task and start it, but the
procedure calling it requires the task to finish before continuing
on. I'm sure I just must be using the wrong mechanisms, but I can't
really figure out the answer.
Task definition
---------------------
(spec)
task type Poll_For_Status is
entry On_String (String : in SideAB)
end Poll_For_Status;
type Task_Access is access Poll_For_Status;
Status_Task : Task_Access;
(body)
task body Poll_For_Status is
begin
accept On_String (String : in SideAB) do
loop
delay 3.0
Send_Status_Req (String);
end loop;
end On_String;
end Poll_For_Status;
Calling procedure
------------------------
procedure Handle_Msg(...) is
String : SideAB;
...
begin
...
Status_Task := new Poll_For_Status
Status_Task.On_String (String);
...
If I remove the loop in the task body, it works fine. Putting it in
seems to halt execution.
Am I missing anything?
next reply other threads:[~2008-05-15 20:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-15 20:51 Bender [this message]
2008-05-15 22:31 ` Running a background task Adam Beneschan
2008-05-15 23:14 ` Adam Beneschan
2008-05-16 0:43 ` Bender
2008-05-16 15:25 ` Adam Beneschan
2008-05-16 15:29 ` Adam Beneschan
2008-05-16 0:16 ` Jeffrey R. Carter
2008-05-16 0:49 ` Bender
2008-05-16 4:32 ` Jeffrey R. Carter
2008-05-16 14:34 ` Bender
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox