--- Compress-LZF/perlmulticore.h 2015/06/28 17:40:38 1.2 +++ Compress-LZF/perlmulticore.h 2015/06/29 23:51:28 1.3 @@ -36,7 +36,7 @@ The newest version of this document can be found at L. -The nwest version of the header fgile itself, which +The newest version of the header file itself, which includes this documentation, can be downloaded from L. @@ -120,7 +120,7 @@ // error, assume lock is held by another process and do it the slow way perlinterp_release (); res = fcntl (fd, F_SETLKW, &flock); - perlinterp_release (); + perlinterp_acquire (); } =head1 THE HARD AND FAST RULES @@ -200,10 +200,6 @@ pthread_mutex_unlock (&my_mutex); perlinterp_acquire (); -This isn't as trivial as it looks though, as you need to find out which -threading system is in use (with L, it currently is -always pthreads). - =item I get confused by having to release first. In many real world scenarios, you acquire a resource, do something, then @@ -306,19 +302,48 @@ =back + +=head1 DISABLING PERL MULTICORE AT COMPILE TIME + +You can disable the complete perl multicore API by defining the +symbol C to C<1> (e.g. by specifying +F<-DPERL_MULTICORE_DISABLE> as compiler argument). + +This will leave no traces of the API in the compiled code, suitable +"empty" C and C definitions will be provided. + +This could be added to perl's C when configuring perl on +platforms that do not support threading at all for example. + + =head1 AUTHOR Marc A. Lehmann + http://perlmulticore.schmorp.de/ =head1 LICENSE -The F is put into the public domain. Where this is legally -not possible, or at your option, it can be licensed under creativecommons -CC0 license: L. +The F header file is put into the public +domain. Where this is legally not possible, or at your +option, it can be licensed under creativecommons CC0 +license: L. =cut + */ +#define PERL_MULTICORE_MAJOR 1 /* bumped on incompatible changes */ +#define PERL_MULTICORE_MINOR 0 /* bumped on every change */ + +#if PERL_MULTICORE_DISABLE + +#define perlinterp_release() do { } while (0) +#define perlinterp_acquire() do { } while (0) + +#else + +/* this struct is shared between all modules, and currently */ +/* contain only the two function pointers for release/acquire */ struct perl_multicore_api { void (*pmapi_release)(void); @@ -335,11 +360,14 @@ #define perlinterp_release() perl_multicore_api->pmapi_release () #define perlinterp_acquire() perl_multicore_api->pmapi_acquire () +/* this is the release/acquire implementation used as fallback */ static void perl_multicore_nop (void) { } +/* this is the initial implementation of "release" - it initialises */ +/* the api and then calls the real release function */ static void perl_multicore_init (void) { @@ -367,3 +395,5 @@ } #endif + +#endif