Boost logo

Boost :

From: bill_kempf (williamkempf_at_[hidden])
Date: 2002-01-30 16:33:37

OK, we've discovered the need to move some things I'd considered
implementation details into some form of public interface. My
thinking is to define some traits classes that allow these details to
be specified. The first "draft" of a mutex_traits<> type looks like

template <typename Mutex>
class mutex_traits
    typedef <i>Implementation Defined</i> cv_state;
    static void lock(Mutex& mutex);
    static void trylock(Mutex& mutex);
    static void timedlock(Mutex& mutex);
    static void unlock(Mutex& mutex);
    static void lock(Mutex& mutex, cv_state& state);
    static void unlock(Mutex& mutex, const cv_state& state);

From a design standpoint, is it OK to use this with types such as
boost::mutex which don't support all the methods, or do we need
seperate traits classes for try and timed mutex variants? The
compiler will catch misuses when using a single traits template, but
I'm still not sure that it's "proper" to design this with a single
traits type.

The other issue is that the above definition won't map to a
read_write_mutex which doesn't have a lock() operation but instead
has a read_lock() and a write_lock() operation. I'm not sure how to
deal with this, or if I actually should deal with it.


Bill Kempf

Boost list run by bdawes at, gregod at, cpdaniel at, john at