|
Boost : |
From: Luis Coelho (deepblack9_at_[hidden])
Date: 2001-04-24 18:48:18
Em Terça, 24 de Abril de 2001 22:09, escreveste:
> I'd like to propose this reader-writer lock as an addition to the boost
> library.
>
> It supports the basic interface:
>
> void lock();
> void unlock();
> void lock() const;
> void unlock() const;
>
> Any number of threads are allowed into the critical section if the const
> version of lock is used, but at most one thread is allowed into the
> critical section if the non-const versions is called.
IMHO, distinguishing between read locks and write locks by const is an
interface mistake. It is better to just have two functions:
lock_read();
lock_write();
Or perhaps:
enum lock_type { read, write };
lock(lock_type);
Which is not so good since enums are not that type safe, but one could
improve upon the idea of having a lock function taking the type of lock as an
argument. I prefer two functions however.
As for unlock, won't a single version (non-const) do?
Regards,
-- Luis Pedro Coelho. Check out my game of Hearts, a card game, for KDE at: http://www.geocities.com/deepblack9/index.html
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk