Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Atomic - qsharepointer
Forum Updated to NodeBB v4.3 + New Features

Atomic - qsharepointer

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Porody
    wrote on last edited by
    #1

    Hi boys,

    What does the term "operate atomic " for QSharedPointer ?

    see http://qt-project.org/doc/qt-4.8/qsharedpointer.html.
    paragraph: Thread-Safety

    Can you give an example?

    thank you

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      See "the definition":http://en.wikipedia.org/wiki/Linearizability. In short - an atomic operation is one that is so "small" (hence the name) that it cannot be interrupted (for example by another thread) and therefore is thread-safe.

      (Z(:^

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Porody
        wrote on last edited by
        #3

        ok thanky you,

        is not possible perform some atomic operation on two threads with two core processor at the same time.

        sorry for my English :)

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Not sure I got you there...

          If you have 2 separate threads that are doing separate work (they don't need to share any resources), then you are completely safe, even if you don use atomic operations, mutexes, monitors etc. A need to use atomics/ mutexes arises when you need to share some piece of data between the threads. Atomics are very convenient, because they allow you to forget (well, almost) about standard caveats of multithreaded programming, because they will simply not allow a deadlock to happen.

          I'm quite certain that is not what you meant, though.

          (Z(:^

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Porody
            wrote on last edited by
            #5

            thanky you,

            and When it is written : QSharedPointer and QWeakPointer are thread-safe and operate atomically on the pointer value

            This means that all operations with QSharedPointer are thread-safe?

            Example:
            operator->()... atomic operation
            data ()...atomic operation
            ....

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved