#define CVf_NODEBUG 0x0020 /* no DB::sub indirection for this CV
(esp. useful for special XSUBs) */
#define CVf_METHOD 0x0040 /* CV is explicitly marked as a method */
-#define CVf_LOCKED 0x0080 /* CV locks itself or first arg on entry */
+#define CVf_LOCKED 0x0080 /* CV locks itself, package or first arg on entry */
+#define CVf_PACKAGE 0x0100 /* CV locks package on entry */
#define CvCLONE(cv) (CvFLAGS(cv) & CVf_CLONE)
#define CvCLONE_on(cv) (CvFLAGS(cv) |= CVf_CLONE)
#define CvLOCKED(cv) (CvFLAGS(cv) & CVf_LOCKED)
#define CvLOCKED_on(cv) (CvFLAGS(cv) |= CVf_LOCKED)
#define CvLOCKED_off(cv) (CvFLAGS(cv) &= ~CVf_LOCKED)
+
+#define CvPACKAGE(cv) (CvFLAGS(cv) & CVf_PACKAGE)
+#define CvPACKAGE_on(cv) (CvFLAGS(cv) |= CVf_PACKAGE)
+#define CvPACKAGE_off(cv) (CvFLAGS(cv) &= ~CVf_PACKAGE)
+
Indicates that the invoking subroutine is a method.
+=item package
+
+If the subroutine is locked, lock the package in which it is
+defined.
+
=item locked
Setting this attribute is only meaningful when the subroutine or
-method is to be called by multiple threads. When set on a method
-subroutine (i.e. one marked with the B<method> attribute above),
-perl ensures that any invocation of it implicitly locks its first
-argument before execution. When set on a non-method subroutine,
-perl ensures that a lock is taken on the subroutine itself before
-execution. The semantics of the lock are exactly those of one
-explicitly taken with the C<lock> operator immediately after the
-subroutine is entered.
+method is to be called by multiple threads. When the B<package>
+attribute is set then before executing the subroutine or method
+perl acquires a lock on the package in which the subroutine is
+defined.
+
+Otherwise, when set on a method subroutine (i.e. one
+marked with the B<method> attribute above), perl ensures that any
+invocation of it implicitly locks its first argument before
+execution. When set on a non-method subroutine,
+(without a B<package> attribute) perl ensures that a lock is taken
+on the subroutine itself before execution. The semantics of the
+lock are exactly those of one explicitly taken with the C<lock>
+operator immediately after the subroutine is entered.
=back
return CVf_METHOD;
else if (strnEQ(attr, "locked", 6))
return CVf_LOCKED;
+ else if (strnEQ(attr, "package", 7))
+ return CVf_PACKAGE;
else
return 0;
}
XPUSHs(sv_2mortal(newSVpv("method", 0)));
if (CvFLAGS(sub) & CVf_LOCKED)
XPUSHs(sv_2mortal(newSVpv("locked", 0)));
+ if (CvFLAGS(sub) & CVf_PACKAGE)
+ XPUSHs(sv_2mortal(newSVpv("package", 0)));
*/
MUTEX_LOCK(CvMUTEXP(cv));
if (CvFLAGS(cv) & CVf_LOCKED) {
- MAGIC *mg;
- if (CvFLAGS(cv) & CVf_METHOD) {
+ MAGIC *mg;
+ if (CvFLAGS(cv) & CVf_PACKAGE) {
+ sv = (SV *) CvGV(cv);
+ }
+ else if (CvFLAGS(cv) & CVf_METHOD) {
if (SP > stack_base + TOPMARK)
sv = *(stack_base + TOPMARK + 1);
else {