|
Boost : |
From: Phillip Hellewell (sshock_at_[hidden])
Date: 2007-07-20 15:55:55
Actually I don't want to copy a mutex. I just want my class that has a
mutex to be copyable, without having to write a copy ctor and operator=
(that copy everything except the mutex).
Using this class solves the problem for me, but I have a feeling it is not
safe to do this.
class recursive_mutex_ignorecopy : public boost::recursive_mutex
{
public:
recursive_mutex_ignorecopy() : boost::recursive_mutex() {}
~recursive_mutex_ignorecopy() {}
recursive_mutex_ignorecopy(const recursive_mutex_ignorecopy&) {}
recursive_mutex_ignorecopy& operator=(const recursive_mutex_ignorecopy&) {}
};
Is this a good solution that could maybe be made part of boost, in such a
way that it is guaranteed to work and be safe?
Or is there a better solution?
Thanks,
Phillip Hellewell
P.S. Perhaps this is a moot point, sinceI just realized that for
thread-safety I really need to write my own copy ctor and operator= anyways,
that will be synchronized with my other functions that initialize shared
pointers and stuff. And I need to lock the rhs's mutex too...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk