スレッドサポート
スレッド・サポート・コマンドは、クラスや関数におけるマルチスレッド・プログラミングのサポート・レベルを指定するためのものです。サポートには3つのレベルがあります:threadsafe reentrant およびnonreentrant 。
デフォルトはnonreentrant で、これは関連するクラスや関数を複数のスレッドで呼び出すことができないことを意味します。Reentrant とthreadsafe は、主にクラスで使用されるレベルです。
Reentrant は、関数の各呼び出しが一意のデータを参照することを条件に、参照されるクラス内のすべての関数を複数のスレッドから同時に呼び出すことができることを意味します。一方、threadsafe は、各呼び出しが共有データを参照する場合でも、参照されるクラス内のすべての関数を複数のスレッドから同時に呼び出すことができることを意味します。
クラスが \reentrantまたは \threadsafenonreentrant マークされている場合、そのクラス内の関数は \nonreentrantコマンドを使ってマークできます。
例
/*!
\class QLocale
\brief The QLocale class converts between numbers and their
string representations in various languages.
\reentrant
\ingroup i18n
\ingroup text
QLocale is initialized with a language/country pair in its
constructor and offers number-to-string and string-to-number
conversion functions similar to those in QString.
...
\nonreentrant
Sets the global default locale to \a locale. These values are
used when a QLocale object is constructed with no
arguments. If this function is not called, the system's locale
is used.
\warning In a multithreaded application, the default locale
should be set at application startup, before any non-GUI
threads are created.
\sa system(), c()
*/
void QLocale::setDefault(const QLocale &locale)
{
default_d = locale.d;
}QDocはクラスが再入可能と宣言されたときに通知を生成し、例外(宣言された再入可能でない関数)をリストします。再入可能性とスレッド安全性に関する一般的なドキュメントへのリンクが含まれています。さらに、「警告:この関数はリエントラントではありません。" という警告が、リエントラントでない関数のドキュメントに表示されます。
QDocはクラスがスレッドセーフと宣言されたときにも同じ通知と警告を生成します。
詳しくは再入可能性とスレッドセーフに関する一般的なドキュメントを参照してください。
コマンド
\threadsafe
\threadsafe コマンドには、関連するクラスや関数がスレッドセーフであり、複数のスレッドから同時に呼び出すことができることを示す行がドキュメントに含まれています。
このコマンドはそれ自身の行に記述しなければならない。
このコマンドから生成されるドキュメントは \reentrantコマンドに対して生成されるものと似ている。上記の導入部の例を参照してください。
また \reentrantと \nonreentrant.
\reentrant
\reentrant コマンドは、関連するクラスや関数を複数のスレッドから同時に呼び出すことができることを示します。上の例を参照してください。
コマンドはそれ自身の行に記述しなければならない。
また \nonreentrantと \threadsafe.
\nonreentrant
\nonreentrant コマンドは、関連するクラスや関数を複数のスレッドから呼び出すことができないことを示す。Nonreentrantがデフォルトのケースです。
コマンドはそれ自身の行に記述しなければならない。
クラスが \reentrantまたは \threadsafeマークされている場合、そのクラス内の関数は、nonreentrant 。 \fnのコメントでマークすることができます。
また \reentrantおよび \threadsafe.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.