NAME

Coro::RWLock - reader/write locks

SYNOPSIS

use Coro::RWLock;

$lck = new Coro::RWLock;

$lck->rdlock; # acquire read lock

$lck->unlock;

DESCRIPTION

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).

$l = new Coro::RWLock;

Create a new reader/writer lock.

$l->rdlock

Acquire a read lock.

$l->tryrdlock

Try to acquire a read lock.

$l->wrlock

Acquire a write lock.

$l->trywrlock

Try to acquire a write lock.

$l->unlock

Give up the rwlock.

AUTHOR

Marc Lehmann <pcg@goof.com>
http://www.goof.com/pcg/marc/