Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
RWLock(3)	      User Contributed Perl Documentation	     RWLock(3)

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->unlock; #	unlock lock again

	# try a	readlock
	if ($lck->tryrdlock) {
	   ...;
	   $l->unlock;
	}

	# try a	write lock
	if ($lck->trywrlock) {
	   ...;
	   $l->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).

       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 <schmorp@schmorp.de>
	  http://software.schmorp.de/pkg/Coro.html

perl v5.32.0			  2020-07-29			     RWLock(3)

NAME | SYNOPSIS | DESCRIPTION | AUTHOR/SUPPORT/CONTACT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Coro::RWLock&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help