Results 1 to 3 of 3

Thread: good approach? (QAbstractItemModel with a read-write lock)

  1. #1
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default good approach? (QAbstractItemModel with a read-write lock)

    (note : i have little experience with multithreading and thread safety)

    i needed my item model to interact with objects from different threads, so i added a QReadWriteLock to the model (specified it mutable), and lock from any call that either read or writes (made sure that a the model doesn't deadlock itself logic-wise)

    is this a good approach, or am i planting landmines?

  2. #2
    Join Date
    Apr 2010
    Location
    Russian Federation, Kaluga
    Posts
    20
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: good approach? (QAbstractItemModel with a read-write lock)

    Hi, I think it's a good approach.
    And... I think than using QReadLocker and QWriteLocker is more safe than QReadWriteLock::lock(), QReadWriteLock::unlock() =)

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: good approach? (QAbstractItemModel with a read-write lock)

    It is not a very good approach however it shouldn't blow up in your face. Please specify how are you accessing the model from different threads and why.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 2nd November 2010, 06:15
  2. sqlite read lock.
    By gilgm in forum Qt Programming
    Replies: 6
    Last Post: 18th June 2010, 06:58
  3. Something good to read about QSqlDatabase
    By Morea in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2008, 23:31
  4. Read/Write on a konsole from Qt app
    By Joccy in forum Qt Programming
    Replies: 9
    Last Post: 4th February 2008, 13:21
  5. XML -read-write
    By hgedek in forum Qt Programming
    Replies: 2
    Last Post: 3rd September 2007, 19:10

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.