Boost Users :
Subject: Re: [Boost-users] How to use lock_guard
From: Oliver Seiler (oseiler_at_[hidden])
Date: 2009-03-17 13:29:48
On Tue, Mar 10, 2009 at 8:51 AM, Roman Perepelitsa
> You should not manually call destructors of automatic (stack allocated)
> objects. It's an Undefined Behavior and in practice it usually causes
> destructor to be called twice. You might want to put lock_guard in
> additional scope.
> boost::lock_guard<boost::mutex> lock(_mut);
> // Data received from RS232
> // .... CODE ....
> } // Destructor of lock is called here.
> signal_OnData(); }
Or use unique_lock or scoped_lock:
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