1

I am not able to find any spinlock in Qt library. Does Qt don't have any? How can we implement cross-platform(Win-Linux-Mac) spinlock in Qt?

Qt 5: http://doc.qt.io/qt-5/threads-synchronizing.html

Qt 4: http://doc.qt.io/qt-4.8/threads-synchronizing.html

Matt
  • 14,906
  • 27
  • 99
  • 149
rishygupta
  • 11
  • 2
  • You may use any alomic types. Qt or STL. – Dmitry Sazonov Jan 19 '16 at 12:02
  • 1
    Here's an example: https://gist.github.com/aperezdc/5582452 – JKSH Jan 19 '16 at 12:09
  • There is QLockFile or QSharedMemory, which could be used for this – Sebastian Lange Jan 19 '16 at 12:30
  • erk... may I ask why do you possibly need a spinlock, yet you don't know how to implement one? – peppe Jan 19 '16 at 13:44
  • 2
    Perhaps if you described the problem you are trying to solve (with spinlocks) instead of the solution you are looking for, you might get some better responses. It's been a long time since I have actually needed a true spinlock, usually there are other mechanisms that are more CPU friendly available. – jwernerny Jan 19 '16 at 13:59
  • Why not using a QMutex? See http://stackoverflow.com/questions/5869825/when-should-one-use-a-spinlock-instead-of-mutex – Murphy Jan 19 '16 at 22:03

0 Answers0