Boost logo

Boost :

From: Kevin Atkinson (kevin_at_[hidden])
Date: 2003-02-19 14:13:59


On Wed, 19 Feb 2003, Kevin Atkinson wrote:

> On Wed, 19 Feb 2003, Alexander Terekhov wrote:
>
> > Kevin Atkinson wrote:
>
> > > > static const pthread_mutex_t MUTEX_INIT = PTHREAD_MUTEX_INITIALIZER;
> > > >
> > > > class Mutex {
> > > > pthread_mutex_t l_;
> > > > public:
> > > > Mutex() : l_(MUTEX_INIT) {}"
> > > > ^^^^^^^^^^^^^^
> > >
> > > I believe this behavior is well defined. ....
> > "....
> > Only /mutex/ itself may be used for performing synchronization.
> > The result of referring to copies of /mutex/ in calls to <snip>
> > is undefined."
> >
> > End of story.
>
> You ignored the rest of my argument. Neither the right hand side or the
> left hand side of the assignment involve a mutex that has ever been used
> in any way by any function. It may be technically undefined by the POSIX
> standard however I can not see any way that this can do any harm. I
> challenge you to find an implementation in which what I did will cause a
> problem, or for that matter an hypothetical implementation.

Alright after reading the standard a bit closer on the behavior
PTHREAD_MUTEX_INITIALIZER. It says it can be used to statically
initialize a mutex and implies it may only be used in the form of
"pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER". However I do not see
how:

  static const pthread_mutex_t MUTEX_INIT = PTHREAD_MUTEX_INITIALIZER;
  pthread_mutex_t mutex = MUTEX_INIT.

is functionally different than the form it gives.

-- 
http://kevin.atkinson.dhs.org

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk