17 Mar
2009
17 Mar
'09
5:29 p.m.
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_guardboost::mutex lock(_mut); // Data received from RS232 _device.GetData(_buffer); // .... CODE .... } // Destructor of lock is called here. signal_OnData(); }
Or use unique_lock or scoped_lock: boost::mutex::scoped_lock lock(_mut); .... lock.unlock(); signal_OnData();