[Interest] QMap and thread-safe.
André Somers
andre at familiesomers.nl
Wed Jul 24 10:50:54 CEST 2013
Op 24-7-2013 9:29, Mandeep Sandhu schreef:
> On Wed, Jul 24, 2013 at 12:20 PM, André Somers <andre at familiesomers.nl
> <mailto:andre at familiesomers.nl>> wrote:
>
> Op 23-7-2013 13:34, Giuseppe D'Angelo schreef:
> > On 23 July 2013 13:25, Bill Crocker <william.crocker at analog.com
> <mailto:william.crocker at analog.com>> wrote:
> >> Hi all:
> >>
> >> The QMap class states that all member functons are reentrant, but
> >> if I populate a map at program start-up (with QStrings, let's
> say) and I
> >> do not change its contents from then on... I should be able to
> treat the
> >> member function ::contains() and any other member function
> which does not
> >> modify the map as thread-safe.
> >>
> >> Is true?
> > Probably yes, although totally undocumented. (There has been some
> > discussion before the release of 5.0 -- about whether we should make
> > it official that using only "const" methods on containers makes them
> > thread safe, but I don't remember the outcome...)
> >
> > HTH,
> Well, if I understood Herb Sutters talk[1] on this correctly, that
> basically *is* the meaning of const nowadays...
>
> André
>
> [1]
> http://channel9.msdn.com/posts/C-and-Beyond-2012-Herb-Sutter-You-dont-know-blank-and-blank
>
>
> Thanks for sharing this link. It was very informative. (BTW, this
> applies only to C++11)
It does, but because Qt is supposed to work well with C++11, I think it
probably applies to all of Qt, no matter if C++11 is actually used or not.
>
> Also, doesn't a "const" (old sense of the word) member function mean -
> "I'm not going to alter the state of the object" ?
No, it means that you're not going to change the *observable* state of
the object. If you do things like lazy evaluation, your internals may
change even though the observable state does not. That's what mutable is
helping you do.
André
--
You like Qt?
I am looking for collegues to join me at i-Optics!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130724/02932256/attachment.html>
More information about the Interest
mailing list