Thread::RWLock - rwlock implementation for perl threads
use Thread::RWLock; my $rwlock = new Thread::RWLock; # Reader $rwlock->down_read; $rwlock->up_read; # Writer $rwlock->down_write; $rwlock->up_write;
RWLocks provide a mechanism to regulate access to resources. Multiple concurrent reader may hold the rwlock at the same time, while a writer holds the lock exclusively.
New reader threads are blocked if any writer are currently waiting to obtain the lock. The read lock gets through after all write lock requests have completed.
This RWLock implementation also takes into account that one thread may obtain multiple readlocks at the same time and prevents deadlocking in this case.
new creates a new rwlock. The new rwlock is unlocked.
down_read method obtains a read lock. If the lock is currantly held by a writer or writer are waiting for the lock,
down_read blocks until the lock is available.
Releases a read lock previously obtained via
Obtains a write lock from the rwlock. Write locks are exclusive, so no other reader or writer are allowed until the lock is released.
down_write blocks until the lock is available.
Release a write lock previously obtained via
the Thread::Semaphore manpage
Andreas Ferber <email@example.com>