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

Re: Asynchronous callbacks from C

Thread Previous | Thread Next
David M. Lloyd
July 5, 2001 07:43
Re: Asynchronous callbacks from C
Message ID:
On Thu, 5 Jul 2001, Paul Johnson wrote:

> On Thu, Jul 05, 2001 at 08:42:52AM -0500, David M. Lloyd wrote:
> > Exactly what is a plugable runops function?  Is that something that exists
> > in perl today (5.6)?  Is there an API interface to it?
> It is a feature that Malcolm added when he first started on the compiler
> stuff, if I remember correctly.
> Its actually fairly simple, you write your own runops function and tell
> Perl to use it.  See Cover.xs in Devel::Cover for a working example.

OK, I see how it works, and it seems simple.  However, it seems that only
one thing can be using the runops deal at a time.  Also, would using this
method invalidate -DDEBUGGING?

Maybe what I should do is make an XS module that makes a generic callback
interface available to other modules by keeping a linked list of
callbacks... that may be something that other people can use too.

I guess what I'd do is make a few functions available from the module:

/* 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);

- D


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About