How to leverage Qt to make a QObject method thread-safe?
<p>Suppose we wrote a non-const method in a <code>QObject</code>-deriving class:</p>

<pre><code>class MyClass : public QObject {
  int x;
public:
  void method(int a) {
    x = a; // and possibly other things
  };
};
</code></pre>

<p>We want to make that method thread-safe: meaning that calling it from an arbitrary thread, and from multiple threads concurrently, shouldn't introduce undefined behavior.</p>

<ol>
<li><p>What mechanisms/APIs does Qt provide to help us make that method thread-safe?</p></li>
<li><p>What mechanisms/APIs from Qt one could use when the method does the "other things" too?</p></li>
<li><p>Is there any classification possible of the "other things" that would inform what Qt-specific mechanisms/APIs to use?</p></li>
</ol>

<p>Off topic are mechanisms provided by the C++ standard itself, and generic/non-Qt-specific ways of ensuring thread-safety.</p>