comp.lang.ada
 help / color / mirror / Atom feed
* Running a background task
@ 2008-05-15 20:51 Bender
  2008-05-15 22:31 ` Adam Beneschan
  2008-05-16  0:16 ` Jeffrey R. Carter
  0 siblings, 2 replies; 10+ messages in thread
From: Bender @ 2008-05-15 20:51 UTC (permalink / 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?



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-05-16 15:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-15 20:51 Running a background task Bender
2008-05-15 22:31 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox