Boost logo

Boost Users :

Subject: Re: [Boost-users] mutex locking!
From: Wesley Khandavalli (wesleyk_at_[hidden])
Date: 2008-09-04 09:23:18


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_at_[hidden]>wrote:

> "Wesley Khandavalli" <wesleyk_at_[hidden]> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Wesley K
Software Engineer
m: +91 9969628090 | t: +91 2444 8097
wesleyk_at_[hidden] | www.vubites.com


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