Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

coro::rwlock(3pm) [debian man page]

RWLock(3pm)						User Contributed Perl Documentation					       RWLock(3pm)

NAME
Coro::RWLock - reader/write locks SYNOPSIS
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 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). 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
Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/ perl v5.14.2 2012-04-13 RWLock(3pm)

Check Out this Related Man Page

SemaphoreSet(3pm)					User Contributed Perl Documentation					 SemaphoreSet(3pm)

NAME
Coro::SemaphoreSet - efficient set of counting semaphores SYNOPSIS
use Coro; $sig = new Coro::SemaphoreSet [initial value]; $sig->down ("semaphoreid"); # wait for signal # ... some other "thread" $sig->up ("semaphoreid"); DESCRIPTION
This module implements sets of counting semaphores (see Coro::Semaphore). It is nothing more than a hash with normal semaphores as members, but is more efficiently managed. This is useful if you want to allow parallel tasks to run in parallel but not on the same problem. Just use a SemaphoreSet and lock on the problem identifier. You don't have to load "Coro::SemaphoreSet" manually, it will be loaded automatically when you "use Coro" and call the "new" constructor. new [inital count] Creates a new semaphore set with the given initial lock count for each individual semaphore. See Coro::Semaphore. $semset->down ($id) Decrement the counter, therefore "locking" the named semaphore. This method waits until the semaphore is available if the counter is zero. $semset->up ($id) Unlock the semaphore again. If the semaphore reaches the default count for this set and has no waiters, the space allocated for it will be freed. $semset->try ($id) Try to "down" the semaphore. Returns true when this was possible, otherwise return false and leave the semaphore unchanged. $semset->count ($id) Return the current semaphore count for the specified semaphore. $semset->waiters ($id) Returns the number (in scalar context) or list (in list context) of waiters waiting on the specified semaphore. $semset->wait ($id) Same as Coro::Semaphore::wait on the specified semaphore. $guard = $semset->guard ($id) This method calls "down" and then creates a guard object. When the guard object is destroyed it automatically calls "up". $semaphore = $semset->sem ($id) This SemaphoreSet version is based on Coro::Semaphore's. This function creates (if necessary) the underlying Coro::Semaphore object and returns it. You may legally call any Coro::Semaphore method on it, but note that calling "$semset->up" can invalidate the returned semaphore. AUTHOR
Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/ perl v5.14.2 2012-04-13 SemaphoreSet(3pm)
Man Page