Boost logo

Boost Users :

From: Jason Stewart (jstewart_at_[hidden])
Date: 2005-07-29 12:00:48


Try

void foo()
{
        shared_ptr<scoped_lock> lk;
        if (condition)
                lk.reset(new scoped_lock(mutex));

        do something
}

The smart pointer will automatically unlock when it goes out of scope.


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