[Qt-interest] do i need QReadWriteLock?

Pascal Patry iscy at invalidip.com
Fri Apr 17 17:19:21 CEST 2009


On Friday 17 April 2009 06:08:17 Serge wrote:
> Hi,

Hi Serge,

> i have 2 threads
> one is writing to bool value.
> another is only reading its value.
> they can do it simultaneously.
> must i use QReadWriteLock to block reading when writing happens, and
> block writing when reading happens? Or for bool value read/write from 2
> threads will not conflict?

Yes, you should always use proper semantics when dealing with threads.

Here, you should either use read/write locking functions or an atomic 
operation.

> --
> Serge





More information about the Qt-interest-old mailing list