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.
> 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. -
-- rrivera/ - grafik/
-- 102708583/icq - grafikrobot/aim - Grafik/

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at