Subject: Re: [boost] How to implement a reader-writer lock with quick responseto writer?
From: Paul Rose (prose_at_[hidden])
Date: 2008-09-18 11:33:18
You can build a r/w lock that preferrs writers on top of
See the "Write-Priority Read/Write Locks" section of the page:
for an example on top of pthread_cond_t. Converting to
boost:condition_variable should be mostly an exercise in search/replace.
The site is very slow today, you might want to see the Google cache
Essentially you keep a pair of condition variables that share a single
mutex. State is held by two integers. A lock count integer is -1 when
held by writer, 0 for free and >0 when held by readers. A
waiting_writers integer counts the number of waiting writers. New
readers can only acquire the lock when lock_count is >= 0
waiting_writers == zero.
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Bill David
> Sent: Wednesday, September 17, 2008 10:12 AM
> To: boost_at_[hidden]
> Subject: [boost] How to implement a reader-writer lock with
> quick responseto writer?
> How to implement a reader-writer lock with quick response to writer?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk