diff options
author | Dave Mitchell <davem@fdisolutions.com> | 2005-12-29 11:35:04 +0000 |
---|---|---|
committer | Dave Mitchell <davem@fdisolutions.com> | 2005-12-29 11:35:04 +0000 |
commit | 85ce96a160e902929b94338ada20cf46b265d595 (patch) | |
tree | bcb5d1a42e33f1d0cf08bf84c6e485614437e4a5 /pod | |
parent | 705c898ca699069279e27abb37342b93effd7a43 (diff) | |
download | perl-85ce96a160e902929b94338ada20cf46b265d595.tar.gz |
add tests for MY_CXT API and improve its documentation
p4raw-id: //depot/perl@26522
Diffstat (limited to 'pod')
-rw-r--r-- | pod/perlxs.pod | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/pod/perlxs.pod b/pod/perlxs.pod index 462f84ce3f..b3ba08f56a 100644 --- a/pod/perlxs.pod +++ b/pod/perlxs.pod @@ -1921,6 +1921,11 @@ Below is an example module that makes use of the macros. else RETVAL = newSVpv(MY_CXT.name[index - 1]); + void + CLONE(...) + CODE: + MY_CXT_CLONE; + B<REFERENCE> @@ -1956,7 +1961,10 @@ of C<my_cxt_t>. The MY_CXT_INIT macro initialises storage for the C<my_cxt_t> struct. -It I<must> be called exactly once -- typically in a BOOT: section. +It I<must> be called exactly once -- typically in a BOOT: section. If you +are maintaining multiple interpreters, it should be called once in each +interpreter instance, except for interpreters cloned from existing ones. +(But see C<MY_CXT_CLONE> below.) =item dMY_CXT @@ -1977,6 +1985,34 @@ then use this to access the C<index> member dMY_CXT; MY_CXT.index = 2; +=item aMY_CXT/pMY_CXT + +C<dMY_CXT> may be quite expensive to calculate, and to avoid the overhead +of invoking it in each function it is possible to pass the declaration +onto other functions using the C<aMY_CXT>/C<pMY_CXT> macros, eg + + void sub1() { + dMY_CXT; + MY_CXT.index = 1; + sub2(aMY_CXT); + } + + void sub2(pMY_CXT) { + MY_CXT.index = 2; + } + +Analogously to C<pTHX>, there are equivalent forms for when the macro is the +first or last in multiple arguments, where an underscore represents a +comma, i.e. C<_aMY_CXT>, C<aMY_CXT_>, C<_pMY_CXT> and C<pMY_CXT_>. + +=item MY_CXT_CLONE + +By default, when a new interpreter is created as a copy of an existing one +(eg via C<<threads->new()>>), both interpreters share the same physical +my_cxt_t structure. Calling C<MY_CXT_CLONE> (typically via the package's +C<CLONE()> function), causes a byte-for-byte copy of the structure to be +taken, and any future dMY_CXT will cause the copy to be accessed instead. + =back =head1 EXAMPLES |