Results 1 to 4 of 4

Thread: single variable and QMutex

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    30
    Thanked 13 Times in 12 Posts

    Default Re: single variable and QMutex

    Yes, a statement such as

    Qt Code:
    1. foo++;
    To copy to clipboard, switch view to plain text mode 

    can in the object code expand to several instructions. Pseudocode:

    Qt Code:
    1. register = foo;
    2. register += 1;
    3. foo = register;
    To copy to clipboard, switch view to plain text mode 

    If another thread is also executing the same instructions, it may have been interrupted right after the first pseudo-instruction above. The variable will then be incremented only once even when two threads tried to increment it...

  2. The following user says thank you to drhex for this useful post:

    babu198649 (9th December 2008)

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.