Solved

boost::mutex status

Posted on 2012-04-09
2
413 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now