summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2005-12-31 23:24:26 +0000
committerDave Mitchell <davem@fdisolutions.com>2005-12-31 23:24:26 +0000
commit628ab32248927f787ac54b4921d2c16b4d153cea (patch)
treee119d59388c4004d2a5903c022c7b38ce4b5a992
parent4c901e72a9a1fb951bea802158d49869bfdb0dbe (diff)
downloadperl-628ab32248927f787ac54b4921d2c16b4d153cea.tar.gz
make threads use MY_CXT API rather than using PL_modglobal
p4raw-id: //depot/perl@26555
-rwxr-xr-xext/threads/threads.xs25
1 files changed, 16 insertions, 9 deletions
diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs
index baf1b51f14..d19e42552b 100755
--- a/ext/threads/threads.xs
+++ b/ext/threads/threads.xs
@@ -52,6 +52,15 @@ typedef struct ithread_s {
#endif
} ithread;
+#define MY_CXT_KEY "threads::_guts" XS_VERSION
+
+typedef struct {
+ ithread *thread;
+} my_cxt_t;
+
+START_MY_CXT
+
+
ithread *threads;
/* Macros to supply the aTHX_ in an embed.h like manner */
@@ -71,18 +80,13 @@ I32 active_threads = 0;
void Perl_ithread_set (pTHX_ ithread* thread)
{
- SV* thread_sv = newSViv(PTR2IV(thread));
- if(!hv_store(PL_modglobal, "threads::self", 12, thread_sv,0)) {
- croak("%s\n","Internal error, couldn't set TLS");
- }
+ dMY_CXT;
+ MY_CXT.thread = thread;
}
ithread* Perl_ithread_get (pTHX) {
- SV** thread_sv = hv_fetch(PL_modglobal, "threads::self",12,0);
- if(!thread_sv) {
- croak("%s\n","Internal error, couldn't get TLS");
- }
- return INT2PTR(ithread*,SvIV(*thread_sv));
+ dMY_CXT;
+ return MY_CXT.thread;
}
@@ -445,6 +449,8 @@ Perl_ithread_create(pTHX_ SV *obj, char* classname, SV* init_function, SV* param
{
dTHXa(thread->interp);
+ MY_CXT_CLONE;
+
/* Here we remove END blocks since they should only run
in the thread they are created
*/
@@ -765,6 +771,7 @@ ithread_DESTROY(SV *thread)
BOOT:
{
+ MY_CXT_INIT;
#ifdef USE_ITHREADS
ithread* thread;
PL_perl_destruct_level = 2;