1RWLock(3) User Contributed Perl Documentation RWLock(3)
2
3
4
6 Coro::RWLock - reader/write locks
7
9 use Coro;
10
11 $lck = new Coro::RWLock;
12
13 $lck->rdlock; # acquire read lock
14 $lck->unlock; # unlock lock again
15
16 # or:
17 $lck->wrlock; # acquire write lock
18 $lck->tryrdlock; # try a readlock
19 $lck->trywrlock; # try a write lock
20
22 This module implements reader/write locks. A read can be acquired for
23 read by many coroutines in parallel as long as no writer has locked it
24 (shared access). A single write lock can be acquired when no readers
25 exist. RWLocks basically allow many concurrent readers (without
26 writers) OR a single writer (but no readers).
27
28 You don't have to load "Coro::RWLock" manually, it will be loaded
29 automatically when you "use Coro" and call the "new" constructor.
30
31 $l = new Coro::RWLock;
32 Create a new reader/writer lock.
33
34 $l->rdlock
35 Acquire a read lock.
36
37 $l->tryrdlock
38 Try to acquire a read lock.
39
40 $l->wrlock
41 Acquire a write lock.
42
43 $l->trywrlock
44 Try to acquire a write lock.
45
46 $l->unlock
47 Give up a previous "rdlock" or "wrlock".
48
50 Marc A. Lehmann <schmorp@schmorp.de>
51 http://software.schmorp.de/pkg/Coro.html
52
53
54
55perl v5.28.0 2017-08-31 RWLock(3)