It appears that the ": locked" attribute will be eradicated from Perl in 5.10 / Ponie. However, I liked the functionality (previously unknown to me), so I've just implemented
Thread::Synchronize which introduces the ": synchronize" code attribute.
- NAME
- Thread::Synchronize - synchronize subroutine calls between
threads
- SYNOPSIS
use Thread::Synchronize; # activate :synchronize attribute
sub foo : synchronize { } # only one subroutine running at a time
- DESCRIPTION
- This module currently adds one feature to threaded pro-
grams: the ":synchronize" subroutine attribute which
causes calls to that subroutine to be automatically syn-
chronized between threads (only one thread can execute
that subroutine at a time).
Actually, this implementation uses a source filter, so no actual attribute handling is involved during runtime.
Liz
Update:
Changed the name of the module to Thread::Synchronized.