#include "perl.h"
#include "XSUB.h"
+#ifdef USE_ITHREADS
+
#define SHAREDSvPTR(a) ((a)->sv)
/*
CALLER_CONTEXT; \
LEAVE_LOCK; \
} STMT_END
-
+
/*
case SVt_PVCV:
Perl_croak(aTHX_ "Cannot share subs yet");
break;
-
+
default:
ENTER_LOCK;
Perl_sharedsv_associate(aTHX_ &sv, 0, 0);
}
}
else {
+ SvTEMP_off(sv);
SHARED_CONTEXT;
sv_setsv_nomg(SHAREDSvPTR(shared), sv);
CALLER_CONTEXT;
sharedsv_scalar_mg_free(pTHX_ SV *sv, MAGIC *mg)
{
shared_sv *shared = (shared_sv *) mg->mg_ptr;
+#if 0
assert (SvREFCNT(SHAREDSvPTR(shared)) < 1000);
+#endif
Perl_sharedsv_free(aTHX_ shared);
return 0;
}
int
sharedsv_scalar_mg_clear(pTHX_ SV *sv, MAGIC *mg)
{
- shared_sv *shared = (shared_sv *) mg->mg_ptr;
return 0;
}
sharedsv_elem_mg_STORE(pTHX_ SV *sv, MAGIC *mg)
{
dTHXc;
- bool allowed;
shared_sv *shared = SV_to_sharedsv(aTHX_ mg->mg_obj);
shared_sv *target;
SV **svp;
{
dTHXc;
shared_sv *shared = SV_to_sharedsv(aTHX_ mg->mg_obj);
- SV* ssv;
ENTER_LOCK;
sharedsv_elem_mg_FETCH(aTHX_ sv, mg);
if (SvTYPE(SHAREDSvPTR(shared)) == SVt_PVAV) {
PL_sharehook = &Perl_sharedsv_share;
}
+#endif /* USE_ITHREADS */
+
MODULE = threads::shared PACKAGE = threads::shared::tie
PROTOTYPES: DISABLE
+#ifdef USE_ITHREADS
void
PUSH(shared_sv *shared, ...)
PROTOTYPES: ENABLE
void
+_id(SV *ref)
+ PROTOTYPE: \[$@%]
+CODE:
+ shared_sv *shared;
+ if(SvROK(ref))
+ ref = SvRV(ref);
+ if (shared = Perl_sharedsv_find(aTHX_ ref)) {
+ ST(0) = sv_2mortal(newSViv(PTR2IV(shared)));
+ XSRETURN(1);
+ }
+ XSRETURN_UNDEF;
+
+
+void
_refcnt(SV *ref)
PROTOTYPE: \[$@%]
CODE:
croak("cond_broadcast can only be used on shared values");
COND_BROADCAST(&shared->user_cond);
+#endif /* USE_ITHREADS */
+
BOOT:
{
+#ifdef USE_ITHREADS
Perl_sharedsv_init(aTHX);
+#endif /* USE_ITHREADS */
}
+
+
+