Boost logo

Threads-Devel :

From: Allen Pulsifer (pulsifer3_at_[hidden])
Date: 2007-08-03 11:47:50


> http://svn.boost.org/svn/boost/branches/thread_rewrite/boost/b
oost/thread/

Hello Anthony,

Thanks. Glad I asked; I think I'm straight now.

This looks like a standard rwlock implementation: if there is a writer
waiting, then all new readers block. Correct?

One comment: I noticed shared_count is only 10 bits. That's probably large
enough for most applications, but at the same time, small enough that the
counter could rollover in practice, with catastrophic results.

I would suggest:

- byte the bullet and make shared_count 26 bits;

and/or

- test for shared_count reaching its maximum, and then either return busy,
or make additional readers block until 100 or so slots become free (in this
situation, there's no reason to wake waiters every time a reader finishes,
since the machine is probably already overloaded).

Thanks for the implementation,

Allen


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk