View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Marc A. Lehmann > Coro > Coro::RWLock



Annotate this POD


New  2
Open  4
View/Report Bugs
Module Version: 6.514   Source  


Coro::RWLock - reader/write locks


 use Coro;

 $lck = new Coro::RWLock;

 $lck->rdlock; # acquire read lock
 $lck->unlock; # unlock lock again

 # or:
 $lck->wrlock; # acquire write lock
 $lck->tryrdlock; # try a readlock
 $lck->trywrlock; # try a write lock


This module implements reader/write locks. A read can be acquired for read by many coroutines in parallel as long as no writer has locked it (shared access). A single write lock can be acquired when no readers exist. RWLocks basically allow many concurrent readers (without writers) OR a single writer (but no readers).

You don't have to load Coro::RWLock manually, it will be loaded automatically when you use Coro and call the new constructor.

$l = new Coro::RWLock;

Create a new reader/writer lock.


Acquire a read lock.


Try to acquire a read lock.


Acquire a write lock.


Try to acquire a write lock.


Give up a previous rdlock or wrlock.


   Marc A. Lehmann <>
syntax highlighting: