[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: handler function
"Janssen, S.A." <[email protected]> writes:
> Hi,
>
> can someone explain the following to me:
>
> Some objects have a handler() and a recv() method. To me it seems that if
> object A wants to schedule an event at object B,
>
> - it calls schedule and the handle() method at object B is invoked. (Y/N)?
Y
> - When the handle() method at object B doesn't exist, it's recv() method is
> invoked. (Y/N)
Y, assuming that the object derives from NsObject
> - When bypassing the scheduler, object A uses target_->recv(p,h) and object
> B's recv() function is invoked directly by object A (Y/N)?
Y
>
> - So what's the function of the handler exactly?
Most often it's used to schedule a future event. Handler, in fact, is
a container for a callback function. And an event is not necessarily
a packet, it may be e.g. a wake-up call for a queue.
> - Why should you use the bypass instead of always the scheduler (because you
> want to avoid the handler??)
For example, if you want to transfer a packet from one object to
another and you don't need any delay in between, you can directly call
recv method on this object. If you do need a delay however, you use
schedule().
-Yuri