Boost logo

Boost Users :

Subject: [Boost-users] scoped_lock
From: Space Ship Traveller (space.ship.traveller_at_[hidden])
Date: 2009-05-22 01:24:44


I think this is my own fault.

I'm debugging some issues with multi-threading and using boost
scoped_lock.

My code looks like this:

        {
                // Enqueue the notification to be processed
                scoped_lock(m_notifications.lock);
                m_notifications.sources->push(note);
        }

Am I correct in assuming this is not going to work as expected? The
compiler might not even instantiate the lock given this code?

I need to write it like this?

        {
                // Enqueue the notification to be processed
                scoped_lock locked(m_notifications.lock);
                m_notifications.sources->push(note);
        }

Kind regards,
Samuel



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