home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeJava and XSLTSearch this book

8.4. attrs

Sets or gets the attributes of subroutines. Attributes are set for a subroutine at compile time; therefore, setting an invalid attribute results in a compile-time error. Note that attrs has been deprecated. You should use the attributes form instead. During execution, when you call attrs::get on a subroutine reference or name, it returns the list of attributes that are set. Note that attrs::get is not exported. The old usage of attrs is as follows:

sub test {
    use attrs qw(locked method);
@a = attrs::get(\test);

You should use a form like the following instead:

sub test : locked method { }

You can read more about attributes in the next section.

The valid attributes are:

Meaningful only when the subroutine or method will be called by multiple threads. When set on a subroutine that also has the method attribute set, invoking that subroutine implicitly locks its first argument before execution. On a non-method subroutine, a lock is taken on the subroutine itself before execution. The lock semantics are identical to one taken explicitly with the lock operator immediately after entering the subroutine.

The invoking subroutine is a method.

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.