Boost logo

Boost Users :

From: Rene Rivera (grafik.list_at_[hidden])
Date: 2006-01-01 13:13:26


Phil Endecott wrote:
>>>Can someone help me to understand why boost::thread::mutex is
>>>noncopyable? I expect that there is a good reason, but I can't see it
>>>at the moment.
>>
>>http://www.boost.org/doc/html/threads/faq.html#id2786688
>
>
> Thanks for the link. Here is the text:
>
> Why do Mutexes have noncopyable semantics?
>
> I disagree with the first comment: "The only logical form of copy would
> be to use some sort of shallow copy semantics in which multiple mutex
> objects could refer to the same mutex state." What's wrong with the
> copy of a mutex being a new independent mutex?

Because then it's not a copy semantic, but a plain new construction.

> (There's a problem if
> you copy a locked mutex, but I don't propose to do that.)

But what you propose will work for you only. It won't work for anyone else.

By the way you should read further down, item #6, on the FAQ for how to
put a member mutex in a class and have the copy semantics you want.
There even an example ;-)

-- 
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - Grafik/jabber.org

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net