Solved

boost::mutex status

Posted on 2012-04-09
2
421 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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

839 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