Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-10-17 13:17:51

From: "David Abrahams" <dave_at_[hidden]>
> operator=() contains undefined behavior unless both counter
> objects are part of the same array; you could use std::less to
> get around this. However, I think a comment which describes why
> you're ordering the mutexes in this way would be in order. I
> assume it's to prevent deadlocks in the case where thread A does
> x = y and thread B does y = x at the same time. I am also moved
> to suggest that you define operator< on mutex objects so that
> this idiom is harder to get wrong.

Or a compound lock that would acquire two (or several) mutexes in a specific

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