Atomic - qsharepointer



  • 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


  • Moderators

    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.



  • 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 :)


  • Moderators

    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.



  • 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
    ....


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.