Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-03-22 11:22:27

On Thu, 22 Mar 2001 williamkempf_at_[hidden] wrote:
willia> I've been thinking about this, but haven't coded anything up yet. Let
willia> me ramble on about an implementation.
willia> namespace boost {
willia> struct lock_tag { }
willia> struct trylock_tag { }
willia> struct timedlock_tag { }
willia> template <typename L>
willia> struct lock_traits
willia> {
willia> typedef ... lock_category;
willia> };
willia> };

One thing to keep in mind... the typical purpose of such categories is for
dispatching to different algorithms. However, off the top of my head I
can't imagine why someone would want to do this... isn't it the case that
if you need a trylock or timedlock, just a normal lock won't do?

willia> I can't see any other information that would go into a lock_traits
willia> type. Is there some useful type information that I'm not thinking of
willia> that should go in here?
willia> Also, one of the suggestions was to use a lock_category type that
willia> allows further decoupling of the lock types from the mutex types.
willia> Usage was like this:
willia> boost::lock_category<boost::mutex>::trylock lock(mx);
willia> The problem with this is that there's not a one-to-one correspondance
willia> of lock types to mutex types here. For instance, the
willia> boost::fast_mutex doesn't have a trylock type. I can think of a few
willia> ways to deal with this but was interested in hearing other's thoughts
willia> on this and wondering if there's existing practice for this sort of
willia> thing.

One way to handle this is to allow some types to be void. Another
approach is to break the traits up.



 Jeremy Siek www:
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (219) 631-3906

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