Hi,
I'm working with Leopold in the networked application already mentioned, and I'd like to have a thing clarified. It's about the non periodic tasks and blocking functions (like the network related ones).
At first, I thought that I should implement the task so that it called recv (or recvfrom) and blocked waiting for anything that arrived, like we did with other unix applications. However some things I've read suggest that the updateHook() shouldn't block, by means of a timeout or whatever. Is this correct? And, in case it is, why is this suggested? Isn't the task going to expend more resources with an active poll like this? And what would happen if done the blocking way?
I think that my confusion comes because I don't really understand how non periodic tasks work. When is the updateHook of a non periodic task called? Which events do trigger it?
Thanks in advance.
Greetings,
Miguel.

non periodic and blocking
On Monday 28 April 2008 16:19:51 miguel wrote:
> Hi,
>
> I'm working with Leopold in the networked application already mentioned,
> and I'd like to have a thing clarified. It's about the non periodic tasks
> and blocking functions (like the network related ones).
>
> At first, I thought that I should implement the task so that it called recv
> (or recvfrom) and blocked waiting for anything that arrived, like we did
> with other unix applications. However some things I've read suggest that
> the updateHook() shouldn't block, by means of a timeout or whatever. Is
> this correct? And, in case it is, why is this suggested? Isn't the task
> going to expend more resources with an active poll like this? And what
> would happen if done the blocking way?
>
> I think that my confusion comes because I don't really understand how non
> periodic tasks work. When is the updateHook of a non periodic task called?
> Which events do trigger it?
In a non periodic taks, you may block in updateHook(). The 'problem' is that
when you block in updateHook(), no commands or events are processed by your
task, because that happens just before updateHook() is executed by the
ExecutionEngine. Thus if you loop forever in updateHook(), you'll never
process an incomming commandi.
You can work around that by specifying a timeout on the recv socket (
setsockopt() ) and return from updateHook() to allow to process an incomming
command/event/program script. In order to be sure that updateHook() is called
again by the Orocos thread, call
That example is in the Component Builder's manual as well.
If your component does not use commands events etc. You can just loop forever
in updateHook().
Peter