#include "perl.h"
PerlInterpreter* sharedsv_space;
+perl_mutex sharedsv_space_mutex;
#ifdef USE_ITHREADS
Perl_sharedsv_init(pTHX)
{
sharedsv_space = PERL_GET_CONTEXT;
+ MUTEX_INIT(&sharedsv_space_mutex);
}
/*
void
Perl_sharedsv_thrcnt_inc(pTHX_ shared_sv* ssv)
{
- SHAREDSvLOCK(ssv);
+ SHAREDSvEDIT(ssv);
SvREFCNT_inc(ssv->sv);
- SHAREDSvUNLOCK(ssv);
+ SHAREDSvRELEASE(ssv);
}
/*
Perl_sharedsv_thrcnt_dec(pTHX_ shared_sv* ssv)
{
SV* sv;
- SHAREDSvLOCK(ssv);
SHAREDSvEDIT(ssv);
sv = SHAREDSvGET(ssv);
if (SvREFCNT(sv) == 1) {
}
SvREFCNT_dec(sv);
SHAREDSvRELEASE(ssv);
- SHAREDSvUNLOCK(ssv);
}
#endif
} shared_sv;
extern PerlInterpreter* sharedsv_space;
+extern perl_mutex sharedsv_space_mutex;
void Perl_sharedsv_unlock_scope(pTHX_ shared_sv* ssv);
void Perl_sharedsv_unlock(pTHX_ shared_sv* ssv);
#define SHAREDSvGET(a) (a->sv)
-#define SHAREDSvEDIT(a) PERL_SET_CONTEXT(sharedsv_space)
-#define SHAREDSvRELEASE(a) PERL_SET_CONTEXT(my_perl)
+#define SHAREDSvEDIT(a) { MUTEX_LOCK(&sharedsv_space_mutex);\
+SHAREDSvLOCK((a));\
+PERL_SET_CONTEXT(sharedsv_space);\
+}
+#define SHAREDSvRELEASE(a) { PERL_SET_CONTEXT((a)->owner);\
+SHAREDSvUNLOCK((a));\
+MUTEX_UNLOCK(&sharedsv_space_mutex);\
+}
#define SHAREDSvLOCK(a) Perl_sharedsv_lock(aTHX_ a)
#define SHAREDSvUNLOCK(a) Perl_sharedsv_unlock(aTHX_ a)