i am trying to do the following but it says- error: 'class boost::mutex' has no member named 'lock'


#include <boost/thread/mutex.hpp>

#ifndef __FO__
#define __FO__

class FO{
    private:
        int x;
        boost::mutex guard;
        void setGuard();
        void releaseGuard();
    public:
        boost::mutex mutexVar;
        //boost::detail::thread::lock_ops<boost::mutex> mylock;
        int getX();
        void setX(int);
        //FO();
};

#endif

#include "FO.h"

void FO::setGuard()
{
    guard.lock()

}

void FO::releaseGuard()
{
    guard.unlock();
}

int FO::getX()
{
    int tempX;
    setGuard();
    tempX=x;
    releaseGuard();
    return tempX;
}

void FO::setX(int tempX)
{
    setGuard();
    x=tempX;
    releaseGuard();
}



On Tue, Sep 2, 2008 at 4:20 PM, Anthony Williams <anthony.ajw@gmail.com> wrote:
"Wesley Khandavalli" <wesleyk@vubites.com> writes:

> I want to explicitly lock and unlock mutex. Is it possible and what are the methods?-- Wesley K

Yes, it's possible. boost::mutex implements the Lockable concept.

See
http://www.boost.org/doc/libs/1_36_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.mutex
http://www.boost.org/doc/libs/1_36_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable

Anthony
--
Anthony Williams            | Just Software Solutions Ltd
Custom Software Development | http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users



--
Wesley K
Software Engineer

m: +91 9969628090 | t: +91 2444 8097
wesleyk@vubites.com | www.vubites.com