| tested on | Debian (libperl 5.22, 5.24, 5.26), gentoo (libperl 5.26); requires >=5.10 for hv_fetchs |
|---|---|
| known bugs/limitations | none |
| API stability | moderate (prefer other languages) |
| configuration requirements | Must enable ithreads |
Required major hacks because the perl API doesn't support storing caller context. It is also impossible to register a perl variable for this purpose between init and script load.
The current solution is proposed by Niko Tyni in Debian Bug#1112517:
"PL_modglobal" is a general purpose, interpreter global HV for use by extensions that need to keep information on a per-interpreter basis. In a pinch, it can also be used as a symbol table for extensions to share data among each other. It is a good idea to use keys prefixed by the package name of the extension that owns the data.
On threaded perls, each thread has an independent copy of this variable; each initialized at creation time with the current value of the creating thread's copy.
According to perldoc the calls used by this patch appeared in version 5.8.8 and 5.10.0 (circa end of 2007). The limiting factor seems to be hv_fetchs() and hv_stores() - the rest of the hv API probably existed before.