스레드 지원

스레드 지원 명령은 클래스 또는 함수에서 멀티스레드 프로그래밍에 대한 지원 수준을 지정하는 데 사용됩니다. 지원 수준에는 세 가지가 있습니다: threadsafe, reentrantnonreentrant 입니다.

기본값은 nonreentrant 으로, 관련 클래스나 함수를 여러 스레드에서 호출할 수 없음을 의미합니다. Reentrantthreadsafe 는 주로 클래스에 사용되는 수준입니다.

Reentrant 는 참조된 클래스의 모든 함수를 여러 스레드에서 동시에 호출할 수 있음을 의미하며, 각 함수 호출이 고유한 데이터를 참조하는 경우에 한합니다. threadsafe 은 참조된 클래스의 모든 함수가 각 호출이 공유 데이터를 참조하는 경우에도 여러 스레드에서 동시에 호출할 수 있음을 의미합니다.

클래스가 \reentrant 또는 \threadsafe로 표시된 경우, 해당 클래스의 함수는 \nonreentrant 명령을 사용하여 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

스레드 안전 명령은 문서에 관련 클래스 또는 함수가 스레드 안전하며 개별 호출이 공유 데이터를 참조하는 경우에도 여러 스레드에서 동시에 호출할 수 있음을 나타내는 줄이 포함되어 있습니다.

이 명령은 자체 줄에 있어야 합니다.

이 명령에서 생성되는 문서는 \reentrant 명령에 대해 생성되는 문서와 유사합니다. 소개에서 위의 예를 참조하세요.

재진입자\비재진입자를 참조하세요.

\재진입자

재진입자 명령은 각 호출이 자체 데이터를 참조하는 경우 연결된 클래스 또는 함수를 여러 스레드에서 동시에 호출할 수 있음을 나타냅니다. 위의 예시를 참조하세요.

이 명령은 자체 줄에 있어야 합니다.

비재입력자\threadsafe도 참조하세요.

\비접속자

비참가자 명령은 연결된 클래스 또는 함수를 여러 스레드에서 호출할 수 없음을 나타냅니다. 기본값은 비재입력입니다.

이 명령은 자체 줄에 있어야 합니다.

클래스가 \reentrant 또는 \threadsafe로 표시된 경우, 해당 클래스의 함수는 제외할 함수의 \fn 주석에 이 명령을 사용하여 nonreentrant 으로 표시할 수 있습니다.

재진입자\threadsafe도 참조하세요.

© 2025 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.