Coro::RWLock(3pm)

Coro::RWLock3pm

Reader/write locks

Usage

 use Coro;
 $lck = new Coro::RWLock;
 $lck->rdlock; # acquire read lock
 $lck->unlock; # unlock lock again
 # or:
 $lck->wrlock; # acquire write lock
 $lck->unlock; # unlock lock again
 # try a readlock
 if ($lck->tryrdlock) {
    ...;
    $l->unlock;
 }
 # try a write lock
 if ($lck->trywrlock) {
    ...;
    $l->unlock;
 }

Overview

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.

$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 a previous "rdlock" or "wrlock".

Author/support/contact

   Marc A. Lehmann <[email protected]>
   http://software.schmorp.de/pkg/Coro.html

Releases

8 releases since Debian 6.0 (Squeeze); the text changed 7 times.

  1. 6.0
  2. 7
  3. 8
  4. 9
  5. 10
  6. 11
  7. 12
  8. 13

From libcoro-perl 6.570-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.