Solved

boost::mutex status

Posted on 2012-04-09
2
423 Views
Last Modified: 2012-04-11
OK. I am getting a mutex lock like this...

boost::mutex::scoped_lock  lock(mMutex);

where

boost::mutext mMutex

Now how do I check the status of the lock (if lock was gain or not). Some true/false status is fine. How do I do that in boost?
0
Comment
Question by:prain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
evilrix earned 125 total points
ID: 37824864
Using this lock it will always be gained. If you want the option to take a different action if it's not possible you need to use the try lock.

boost::mutex::scoped_try_lock  lock(mMutex);
bool locked = lock.owns_lock();

Open in new window


http://www.boost.org/doc/libs/1_49_0/doc/html/thread/synchronization.html#thread.synchronization.locks.scoped_try_lock
0
 

Author Closing Comment

by:prain
ID: 37833282
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question