From: williamkempf_at_[hidden]
Date: 2001-07-18 08:59:36


--- In boost_at_y..., "Alexander Terekhov" <terekhov_at_d...> wrote:
>
> > class X {
> > public:
> > mutable boost::mutex mtx;
> > int a;
> > X() : a(0) { }
> > X(const X& other) : a(0) { boost::mutex::lock lock(other.mtx);
a =
> other.a; }
> > ~X() { }
> > };
>
> IMHO the use of "lock" is really confusing here.
> i would suggest to adopt more common "locker" or "guard"..
>
> class X {
> public:
> mutable boost::mutex mtxLock; // mutex is exclusive lock which
does not
> support
> // transfer of lock ownership.
binary
> semaphore is
> // exclusive lock which does
support
> transfer of
> // lock ownership.
> int a;
> X() : a(0) { }
> X(const X& other) : a(0) { boost::mutex::locker locker
(other.mtxLock);
> a = other.a; }
> ~X() { }
> };
>
> or
>
> class X {
> public:
> mutable boost::mutex mtxLock; // mutex is exclusive lock which
does not
> support
> // transfer of lock ownership.
binary
> semaphore is
> // exclusive lock which does
support
> transfer of
> // lock ownership.
> int a;
> X() : a(0) { }
> X(const X& other) : a(0) { boost::mutex::guard guard
(other.mtxLock); a
> = other.a; }
> ~X() { }
> };
>
> --
>
> class Y {
> public:
> mutable boost::semaphore semLock;
> int a;
> Y() : a(0) { }
> Y(const X& other) : a(0) { boost::semaphore::guard
> guard(other.semLock); a = other.a; }
> ~Y() { }
> };

A "lock" is a "locker" or "guard". They are all different names for
the same concept. Or is your objection to the name chosen?

Bill Kempf