NAME

XS::Framework::Manual::SVAPI::threads - XS::Framework THREADED Perl support

THREADED Perl support

XS::Framework strictly sets PERL_NO_GET_CONTEXT option so that you need to have my_perl (aTHX) in scope. This way threaded perl works faster.

XS::Framework concept is all about sharing C code, modules that use XS::Framework cannot have different PERL_NO_GET_CONTEXT state. Because in either case, binary incompability between function signatures would occur.

To help dealing with threaded perls XS::Framework defines my_perl alias at global scope, so you could get rid of annoing pTHX and aTHX in every C function.

This alias resolves to appropriate perl interpreter pointer in such a way that it costs almost nothing until you create second thread. This is in contrast to perl's default dTHX or PERL_GET_THX which are relatively expensive at C-speeds. After second thread is created, the alias reverts to PERL_GET_THX speeds.

Keep in mind that threaded perl will definitely be slower than standart perl even if you don't create threads because of penalties in perl source code itself. Penalties are usually 20-50% so i would not recommend using threaded perl unless you *really* need perl threads.

Keep in mind that if you call functions with pTHX in theirs signature or call perl functions (not macros, for example Perl_* functions) you still need to pass aTHX manually. However the speedups covered above still apply to aTHX.

SEE ALSO

XS::Framework

XS::Framework::Manual::SVAPI