Results 1 to 2 of 2

Thread: Reads from multiple threads on a single instance of a QMap

  1. #1
    Join Date
    Dec 2007
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Reads from multiple threads on a single instance of a QMap

    Is it safe to do reads on a single instance of a QMap from multiple threads? I realize that writes would be totally unsafe.

    I could make copies of the QMap and pass them into the threads because they are implicitly shared and the copy would be fast, but I wonder if that is necessary. In other words are there private variables in a QMap that might be corrupted if there were simultaneous lookups from multiple threads?

    I know that an implicit copy copies the QMap object itself, but not the key/value data pointer. Therefore I think I need to send each thread its own implicit copy to be safe.

    Thanks for the advice.
    Last edited by KenW; 13th April 2011 at 21:05.
    "Computers are to be sold, not used"

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Reads from multiple threads on a single instance of a QMap

    As general rule, multiple concurrent readings should not be a problem.
    A camel can go 14 days without drink,
    I can't!!!

  3. The following user says thank you to mcosta for this useful post:

    KenW (14th April 2011)

Similar Threads

  1. Single Application Instance
    By BadKnees in forum Qt Programming
    Replies: 8
    Last Post: 4th November 2014, 14:57
  2. Single instance
    By franco.amato in forum Qt Programming
    Replies: 38
    Last Post: 1st February 2011, 23:27
  3. Replies: 2
    Last Post: 3rd May 2010, 10:57
  4. Replies: 3
    Last Post: 26th March 2010, 07:26
  5. single instance app
    By bnilsson in forum Qt Programming
    Replies: 2
    Last Post: 1st August 2009, 08:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.