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

Re: [PATCH] Adding callbacks to the core

Thread Previous | Thread Next
From:
Arthur Bergman
Date:
August 22, 2001 00:40
Subject:
Re: [PATCH] Adding callbacks to the core
Message ID:
023101c12ade$702c6af0$21000a0a@vogw2kdev


> Here's the patches necessary to add C callbacks to the core.  Per your
> suggestions, I have rolled the callback check into the signal check code.
>
> All tests pass on RH Linux 7.1 and Solaris 2.8.
>
> Patches are against 11709.
>
> Please send me your comments/abuse.
>
> - D
>
> <dmlloyd@tds.net>

Benchmarks benchmarks benchmarks benchmarks.



>      > + CALLBACK *cur, *next;
> +
> +        for (cur = PL_callback_head; cur != NULL; cur = next) {
> +            next = cur->next;
> +            (*cur->callback)(cur->data);
>

You need to give the PerlInterpreter to the callback,

> +PERLVARI(Icallback_head, CALLBACK *, NULL)  /* Pointer to first waiting callback */
> +PERLVARI(Ievent_pending, int, 0)        /* Flag that indicates that an event is pending */
> +
> +#if defined(USE_THREADS) || defined(USE_ITHREADS)
> +PERLVAR(Icallback_mutex, perl_mutex) /* Mutex for adding callbacks in a threadsafe manner */
> +#endif

Under ithreads, the callbacks are by interpreter, hence there is no need to lock the list of callbacks. However there is a need to
add the relevant code to sv.c:perl_clone to properly duplicate the callback structure. I suspect the best would be just to copy all
the structs and let the callback be aware of under what perl interpreter it was called.

Arthur


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