Solved

boost::mutex status

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to split this in C++ 4 102
C++ question 3 65
Safe conversion? 4 67
Installshield for Embarcadero EX 10.1 Berlin 4 40
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

772 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