develooper Front page | perl.perl5.porters | Postings from July 2001

Re: Asynchronous callbacks from C

Thread Previous | Thread Next
From:
Paul Johnson
Date:
July 6, 2001 16:09
Subject:
Re: Asynchronous callbacks from C
Message ID:
20010707021127.G6367@pjcj.net
On Thu, Jul 05, 2001 at 01:16:31PM -0500, David M. Lloyd wrote:
> On Thu, 5 Jul 2001, Paul Johnson wrote:
> > On Thu, Jul 05, 2001 at 09:39:33AM -0500, David M. Lloyd wrote:
> > > /* Returns a 'handle' that can be used to remove a callback */
> > > int add_callback(void (*callback)(void *data), int enable_cb);
> > > 
> > > /* Remove a callback from the list */
> > > void remove_callback(int handle);
> > > 
> > > /* Set's the 'enable' flag so that a callback is called at next
> > >    opportunity (this function would be async-safe */
> > > void enable_callback(int handle, void *data);
> > 
> > What is data in each of these cases?
> 
> You would set 'data' in 'enable_callback', and then when the loop comes
> 'round, 'data' would be passed to (*callback) as the first parameter.  
> That way you can pass data to your callback.

OK, I thought as much, but I'm a little confused by your interface.

Does add_callback call enable_callback?  If so it requires a data
parameter.  If not it doesn't require enable_cb.  (Unless I
misunderstand enable_cb.)

Should there be a disable_callback?  Maybe enable_callback isn't even
needed?  You could just work with add and delete.

You are expecting the callbacks to be called inbetween every opcode,
right?  Or were you thinking that after being called the callback would
become disabled?

-- 
Paul Johnson - paul@pjcj.net
http://www.pjcj.net

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About