Boost logo

Boost :

From: Lie-Quan Lee (llee1_at_[hidden])
Date: 2001-03-19 17:47:10


At Mon, 19 Mar 2001 22:16:47 -0000,
williamkempf_at_[hidden] wrote:

> >
> > > A "lock_tag" might be useful. I'm not sure that full blown
> traits
> > > would be, at least with the types as defined today. Can you
> > > illustrate how these concepts could be useful?
> >
> > I think that all general comments of using traits can be applied
> > here. For exmaple, using "mutex::lock" put a stronger requirement on
> > mutex type.
>
> I'm probably being dense, but I don't see how. Could you please
> illustrate with some code?

By a stronger requirement in the example "mutex:lock", I means lock
type has to be inside of mutex type. Meanwhile by using a traits, that
is not necessary. Any mutex implementation which has corresponding
lock type through traits can be used to construct the lock.
For example, you have your own mutex class,

Bill_mutex {
  ...
};

Somehow you forgot to define lock/trylock/timedlock inside :-).
I may write a traits specialization to despatch to right lock types.

template <>
lock_categories<Bill_mutex> {
  typedef Bill_mutex_lock lock;
  ...
};

Although You might argue that to write a wrapper class,
new_Bill_mutex, adding the lock types in to conform the type requirement.

--
Lie-Quan Lee

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk