Sponsored Content
Operating Systems AIX Sad me - or Happy me? Undecided re: AIX 7.2 Post 302958826 by agent.kgb on Monday 26th of October 2015 05:33:09 PM
Old 10-26-2015
from Koblenz? locker! :-)
 

3 More Discussions You Might Find Interesting

1. What is on Your Mind?

A Sad Day for Smarty Jones!

We were at Champs watching the Belmont on two 15' screens. SMARTY JONE!! SMARTY JONES!!! Then, sadness........ the crowd goes quiet. There are many people who have not seen a triple crown winner in their lifetime...... Amazing... Horse racing! (8 Replies)
Discussion started by: Neo
8 Replies

2. What is on Your Mind?

Does modernity make you sad?

One more "on my mind" question ('cause it's constantly on my mind): does modern technology style make you sad and wishing PCs were like they used to be in 90's? I mean we had awesome UIs like motif, win3.1, warp3/4, cde, etc... HDDs used to load with sound. Web used to be a text on a white... (7 Replies)
Discussion started by: guest115
7 Replies

3. What is on Your Mind?

While Happy; do @ ;done < 2015

http://i62.tinypic.com/zt6a08.jpg (2 Replies)
Discussion started by: ongoto
2 Replies
QMutexLocker(3qt)														 QMutexLocker(3qt)

NAME
QMutexLocker - Simplifies locking and unlocking QMutexes SYNOPSIS
All the functions in this class are thread-safe when Qt is built with thread support.</p> #include <qmutex.h> Public Members QMutexLocker ( QMutex * mutex ) ~QMutexLocker () QMutex * mutex () const DESCRIPTION
The QMutexLocker class simplifies locking and unlocking QMutexes. The purpose of QMutexLocker is to simplify QMutex locking and unlocking. Locking and unlocking a QMutex in complex functions and statements or in exception handling code is error prone and difficult to debug. QMutexLocker should be used in such situations to ensure that the state of the mutex is well defined and always locked and unlocked properly. QMutexLocker should be created within a function where a QMutex needs to be locked. The mutex is locked when QMutexLocker is created, and unlocked when QMutexLocker is destroyed. For example, this complex function locks a QMutex upon entering the function and unlocks the mutex at all the exit points: int complexFunction( int flag ) { mutex.lock(); int return_value = 0; switch ( flag ) { case 0: case 1: { mutex.unlock(); return moreComplexFunction( flag ); } case 2: { int status = anotherFunction(); if ( status < 0 ) { mutex.unlock(); return -2; } return_value = status + flag; break; } default: { if ( flag > 10 ) { mutex.unlock(); return -1; } break; } } mutex.unlock(); return return_value; } This example function will get more complicated as it is developed, which increases the likelihood that errors will occur. Using QMutexLocker greatly simplifies the code, and makes it more readable: int complexFunction( int flag ) { QMutexLocker locker( &mutex ); int return_value = 0; switch ( flag ) { case 0: case 1: { return moreComplexFunction( flag ); } case 2: { int status = anotherFunction(); if ( status < 0 ) return -2; return_value = status + flag; break; } default: { if ( flag > 10 ) return -1; break; } } return return_value; } Now, the mutex will always be unlocked when the QMutexLocker object is destroyed (when the function returns since locker is an auto variable). The same principle applies to code that throws and catches exceptions. An exception that is not caught in the function that has locked the mutex has no way of unlocking the mutex before the exception is passed up the stack to the calling function. QMutexLocker also provides a mutex() member function that returns the mutex on which the QMutexLocker is operating. This is useful for code that needs access to the mutex, such as QWaitCondition::wait(). For example: class SignalWaiter { private: QMutexLocker locker; public: SignalWaiter( QMutex *mutex ) : locker( mutex ) { } void waitForSignal() { ... ... ... while ( ! signalled ) waitcondition.wait( locker.mutex() ); ... ... ... } }; See also QMutex, QWaitCondition, Environment Classes, and Threading. MEMBER FUNCTION DOCUMENTATION
QMutexLocker::QMutexLocker ( QMutex * mutex ) Constructs a QMutexLocker and locks mutex. The mutex will be unlocked when the QMutexLocker is destroyed. If mutex is zero, QMutexLocker does nothing. See also QMutex::lock(). QMutexLocker::~QMutexLocker () Destroys the QMutexLocker and unlocks the mutex which was locked in the constructor. See also QMutexLocker::QMutexLocker() and QMutex::unlock(). QMutex * QMutexLocker::mutex () const Returns a pointer to the mutex which was locked in the constructor. See also QMutexLocker::QMutexLocker(). SEE ALSO
http://doc.trolltech.com/qmutexlocker.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qmutexlocker.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QMutexLocker(3qt)
All times are GMT -4. The time now is 01:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy