Results 1 to 20 of 24

Thread: Loading data in a thread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Loading data in a thread

    I don't know! Show me why it's not like that?

    Even if threads are interweaved, somewhere deep in the core it will come down to a bunch of instructions being executed one by one. Some of them read a register, some of them write a register. I can understand that if say the writing of a double is stopped in the middle, half of the bytes are right and half of the bytes are wrong. If another few instructions now try to read this double, they will not the number they expect. But when the writing of it continues, eventually the double will be written correctly. Or at what point does a read instruction influence a write instruction that is supposed to be executed at a later time?


    Added after 7 minutes:


    Quote Originally Posted by wysota View Post
    Any such check is useless as conditions may change between the time you make the check and the time you access the data.
    Yes, the data might grow even further, nullifying the chance of reading the same element that is being written.


    Quote Originally Posted by wysota View Post
    You are assuming none of the methods in the gui modify the data structure in any way. If you have an implicitly share class such as QList, you may easily fall out of sync.
    That's correct. The data structure is not returned by any method, there are no signals and slots transporting the QList, it's just a plain old access to loader.data[index]. I don't know about the inner workings of the implicitely shared structures. Does a read access like that modify them ever?

    Quote Originally Posted by wysota View Post
    These classes are not thread-safe and I don't know what we are arguing about. The sole statement should be enough to make you synchronize access to the non-thread-safe object.
    I wasn't aware of arguing, so far I'm only asking question as to why does it happen and I expect more of an answer than "because it's not thread safe". Is it possible, that reading the same element in a QList, that is being written by another thread, screws up the element for good?
    Last edited by Cruz; 28th October 2010 at 13:18.

Similar Threads

  1. Replies: 1
    Last Post: 19th July 2010, 11:43
  2. Replies: 6
    Last Post: 29th April 2009, 18:17
  3. stylesheet loading issue - thread
    By talk2amulya in forum Qt Programming
    Replies: 8
    Last Post: 26th February 2009, 12:53
  4. Loading a QPixmap from raw data
    By pherthyl in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2008, 10:12
  5. Stop the thread during recursivly loading directory
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th May 2007, 19:02

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
  •  
Qt is a trademark of The Qt Company.