Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, July 2007
Looking for a thread-aware QMutex


Message 1 in thread

Hello,

I'm looking for a Qt-class which has the following functionality (in short 
the same as WaitForSingleObjetc with a Mutex)

I have to threads A and B and an object O.
Access to object O should be exclusive per thread. It should also be 
possible that when thread A has already access to object O and I call LOCK 
once again, that it should do nothing than return true. When thread A has 
access and thread B requests access with tryLock(timeout) it should wait 
timeout msec to acquire access.

QMutex is not the thing I'm looking for, because it is not aware of threads.

Does Qt has such a solution or what I can I do to get this functionality?

Best Regards,
Patrick Feistel 


--
 [ signature omitted ] 

Message 2 in thread

On Friday 20 July 2007 07:40:57 Patrick Feistel wrote:
> Hello,
>
> I'm looking for a Qt-class which has the following functionality (in short
> the same as WaitForSingleObjetc with a Mutex)
>
> I have to threads A and B and an object O.
> Access to object O should be exclusive per thread. It should also be
> possible that when thread A has already access to object O and I call LOCK
> once again, that it should do nothing than return true. When thread A has
> access and thread B requests access with tryLock(timeout) it should wait
> timeout msec to acquire access.
>
> QMutex is not the thing I'm looking for, because it is not aware of
> threads.

Uhm, QMutex is exactly what you're looking for :) From 
http://doc.trolltech.com/4.3/qmutex.html#details:

"The QMutex class provides access serialization between threads."

(Also, given your requirement above, be sure to initialize QMutex as a 
recursive mutex. See 
http://doc.trolltech.com/4.3/qmutex.html#RecursionMode-enum).

> Does Qt has such a solution or what I can I do to get this functionality?

-- 
 [ signature omitted ] 

Message 3 in thread

Hi again,

thank you, that is exactly what I'm looking for, but I've not seen the 
recursion mode *hmpf*

Thanks,
Patrick

"Bradley T Hughes" <bhughes@xxxxxxxxxxxxx> schrieb im Newsbeitrag 
news:200707200745.12642.bhughes@xxxxxxxxxxxxxxxx
> On Friday 20 July 2007 07:40:57 Patrick Feistel wrote:
>> Hello,
>>
>> I'm looking for a Qt-class which has the following functionality (in 
>> short
>> the same as WaitForSingleObjetc with a Mutex)
>>
>> I have to threads A and B and an object O.
>> Access to object O should be exclusive per thread. It should also be
>> possible that when thread A has already access to object O and I call 
>> LOCK
>> once again, that it should do nothing than return true. When thread A has
>> access and thread B requests access with tryLock(timeout) it should wait
>> timeout msec to acquire access.
>>
>> QMutex is not the thing I'm looking for, because it is not aware of
>> threads.
>
> Uhm, QMutex is exactly what you're looking for :) From
> http://doc.trolltech.com/4.3/qmutex.html#details:
>
> "The QMutex class provides access serialization between threads."
>
> (Also, given your requirement above, be sure to initialize QMutex as a
> recursive mutex. See
> http://doc.trolltech.com/4.3/qmutex.html#RecursionMode-enum).
>
>> Does Qt has such a solution or what I can I do to get this functionality?
>
> -- 
> Bradley T. Hughes - bhughes at trolltech.com
> Trolltech ASA - Sandakervn. 116, P.O. Box 4332 Nydalen, 0402 Oslo, Norway
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/ 


--
 [ signature omitted ]